query to get the values after 3rd “;”

Last Post 23 Jun 2011 11:52 AM by davidmt. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
vinoth
New Member
New Member

--
23 Jun 2011 07:45 AM
Could you please send me the query to get the values after 3rd “;”

'name;Chennai;chennai;Asp.Net;SQLServer'
'a;b;c;d'
'test;a;title;topic'


output have to be like this :

Asp.net;SQLServer
d
topic
Need very urgent , let me know.


russellb
New Member
New Member

--
23 Jun 2011 08:53 AM
SELECT RIGHT(LEFT(col1, LEN(col1) - CHARINDEX(';', REVERSE(col1))),
CHARINDEX(';', REVERSE(LEFT(col1, LEN(col1) - CHARINDEX(';', REVERSE(col1))))) -1
)
FROM YourTable
vinoth
New Member
New Member

--
23 Jun 2011 09:17 AM
Helo

First of all thanks for ur quick reply.
i need to get the output after third value ,

eg:

'asp.net;name;sql;chennai;test'
'a;b;c;d;e'

o/p have 2 be

sql;chennai;test
d;e

Regards
Vino
davidmt
New Member
New Member

--
23 Jun 2011 11:52 AM
Try this solution

Find the Nth Occurrence of a Character in a String
http://www.sqlservercentral.com/scr...ous/30497/


or use a nested combination of CharIndexes and SubStrings to peel back the 3rd instance.


Acceptable Use Policy
---