troubleshooting Question

Stored Procedure to get Filename from UNC

Avatar of JamesNT
JamesNT asked on
Microsoft SQL Server 2005
3 Comments1 Solution282 ViewsLast Modified:
Let's say we have the following table:

ID       file                                                                    date
1      \\server\share\folder1\folder2\blah.txt           01/01/2010
2     \\server\share\folder1\folder2\blah2.txt          01/01/2010
3     \\server\share\folder1\blah3.txt                       01/01/2010

I need a SQL Stored procedure such that I can get only the file name out of the full UNC - for example:

SELECT getFileName(file) as FileName, date as EntryDate
FROM myTable
WHERE date = 01/01/2010

FileName        EntryDate
blah.txt           01/01/2010
blah2.txt         01/01/2010
blah3.txt         01/01/2010

I'm using SQL Server 2005 and 2008.

Thank you all in advanced.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros