Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-06-01 : 03:10:53
|
| DECLARE @document varchar(64)SELECT @document = 'Reflectors$are$vital$safety' SELECT substring(@document,1,CHARINDEX('$', @document)-1)GOin this though i am getting first string bt how can i get secnd string i like to have individual string ie. output string 1 : reflectors string 2 : are ..... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
vinu.vijayan
Posting Yak Master
227 Posts |
Posted - 2012-06-01 : 04:57:41
|
| Use a Tally Table to do the split as shown in the following link:[url]http://www.sqlservercentral.com/articles/T-SQL/62867/[/url]N 28° 33' 11.93148"E 77° 14' 33.66384" |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-01 : 11:16:56
|
| This is one of the fastest splitters:http://www.sqlservercentral.com/articles/Tally+Table/72993/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-01 : 12:09:10
|
quote: Originally posted by mani_12345 DECLARE @document varchar(64)SELECT @document = 'Reflectors$are$vital$safety' SELECT substring(@document,1,CHARINDEX('$', @document)-1)GOin this though i am getting first string bt how can i get secnd string i like to have individual string ie. output string 1 : reflectors string 2 : are .....
if its always four words separated by $ you can use likeDECLARE @document varchar(64)SELECT @document = 'Reflectors$are$vital$safety' SELECT parsename(REPLACE(@document,'$','.'),4) as firstword,parsename(REPLACE(@document,'$','.'),3) as secondword,parsename(REPLACE(@document,'$','.'),2) as thirdword,parsename(REPLACE(@document,'$','.'),1) as fourthword ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|