Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Patindex - Help

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2013-01-02 : 11:12:13
Hello.

I have a table which has one colunm containing a windows UNC path and file name. I'm trying to find the rows that have a valid file extension. I'm using the query below but its returning no results.

The issue must be the where clause and using patindex can anybody help me.

SELECT sUncPath ,
FileName = REVERSE(LEFT(REVERSE(sUncPath),
CHARINDEX('\', REVERSE(sUncPath), 1) - 1)) ,
SUBSTRING(sUncPath, PATINDEX('%.%', sUncPath) + 1, LEN(sUncPath)) AS Extention
FROM Files_And_folders WHERE PATINDEX('%.[a-z][a-z][a-z]%', sUncPath) = 0

Thank you in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-01-02 : 11:29:25
where patindex(...) > 0


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -