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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 substring query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

88 Posts

Posted - 09/23/2015 :  17:55:19  Show Profile  Reply with Quote
i have the table to store the value:\\file0\shares\_Reporting\Q\BR01\Test.txt

how can i select to get only the file name which is Test.txt?


Edited by - kt on 09/24/2015 10:30:36

Posting Yak Master

129 Posts

Posted - 09/25/2015 :  05:04:18  Show Profile  Reply with Quote
create table test(strVal varchar(max))
insert into test values('\\file0\shares\_Reporting\Q\BR01\Test.txt')
select REVERSE(substring(reverse(strVal),0,PATINDEX('%\%',reverse(strVal)))) from test

Murali Krishna

You live only once ..If you do it right once is enough.......
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000