SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Patindex - Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lemondash
Posting Yak Master

United Kingdom
159 Posts

Posted - 01/02/2013 :  11:12:13  Show Profile  Click to see lemondash's MSN Messenger address  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8683 Posts

Posted - 01/02/2013 :  11:29:25  Show Profile  Visit webfred's Homepage  Reply with Quote
where patindex(...) > 0


Too old to Rock'n'Roll too young to die.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000