May 4, 2010 at 4:28 pm
Morning Folks.
I have a document table, thats has column called Name (nvarchar), This column includes the name and extension of a document for example document1.doc, document2.pdf etc
How do I find document names that do not have an extension?
I can find the extensions using either of the following queires
COALESCE(RIGHT(name, NULLIF(CHARINDEX('.', REVERSE(name)) - 1, -1)), name, '') AS Filename
or
Reverse(left(reverse(name), charindex('.',reverse(name)))) AS FileExtension
but no idea on how to produce the document names that do not have extensions.
May 4, 2010 at 4:33 pm
Ummmm.... wouldn't you just find all the names that don't have a period in them? i.e. Use CHARINDEX or NOT LIKE?
--Jeff Moden
Change is inevitable... Change for the better is not.
May 4, 2010 at 4:34 pm
Something like this?
SELECT *
FROM
(
SELECT 'abc.de' col UNION ALL
SELECT 'abd'
) t
WHERE CHARINDEX('.',col) =0
May 4, 2010 at 5:00 pm
Thanks Lutz
I used your where statement, and I've got the results I need.
May 4, 2010 at 5:03 pm
Glad I could help. 😀
But it was just the coded answer Jeff suggested first... (it's usually the other way around 😀 )
May 4, 2010 at 10:46 pm
~Edit : My bad, posted in the wrong thread! 😀 ! Sorry!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply