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 |
kirank
Yak Posting Veteran
58 Posts |
Posted - 2012-12-25 : 05:25:36
|
Hi,one of my sp return records like this@selectVal= 'a;b;c;d;f;e;r;g;'i have one table call temp_res, on SP i need to write a logic where i can loop thr the string and insert into table(temp_res) just want it to split the result base on ;(semicolun) and insert new recordscan you plz suggest me thanx in advance,---------------------------http://codingstuffsbykiran.blogspot.com | http://webdevlopementhelp.blogspot.com |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-25 : 08:57:32
|
[code];with CTE as (Select ID, LEFT(Data, CHARINDEX(';',Data+';')-1), STUFF(Data, 1, CHARINDEX(';',Data+';'), '')from temp_resunion allselect ID, LEFT(Data, CHARINDEX(';',Data+';')-1), STUFF(Data, 1, CHARINDEX(';',Data+';'), '')from CTEwhere Data > '')Select * from CTEOrder by ID[/code] |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2012-12-25 : 21:12:38
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
kirank
Yak Posting Veteran
58 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-27 : 00:03:52
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|