September 18, 2009 at 3:52 am
I have had a search around and am either looking in the wrong place, or cannot find a solution.
I need to get the string part between the 4th and 5th Back slash
Following examples
\\Server1\projects\17361\Email
\\Server2\live\13025s\13930\wp
\\Server3\simulator\12426\docs\old
Required
17361
13025s
12426
any ideas
Cheers...Steve
September 18, 2009 at 4:15 am
There is a script on this site to find the nth occurence of a character in a string. That should get you started.:-
http://www.sqlservercentral.com/scripts/Miscellaneous/30497/
September 18, 2009 at 7:20 am
thanks Ian helped a lot.
ended up with this, if it is of any intrest.
update tbl_out_test set job_number =
(select substring(location,((dbo.CHARINDEX2('\', location,4)+1)),
((dbo.CHARINDEX2('\', location,5)) - ((dbo.CHARINDEX2('\', location,4))+1))))
where job_number =''
September 18, 2009 at 7:43 am
You may also be interested in Jeff Moden's article on how to split using a tally table (which I couldn't find the reference to this morning). http://www.sqlservercentral.com/articles/T-SQL/62867/
If you adapt your code to one of these, it will perform a lot better than the scalar function I originally pointed you to... but you need a brain the size of a planet to figure out how some of them work, let alone write one from scratch. I'm b******d if I can work some of them out.:-)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply