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 |
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2010-11-12 : 06:57:26
|
I want to convert comma seperated values into rows.TID TCodes TValues1 OEL, LEO, SER 4582 LSE 583 LEO, OEL 63OUTPUTTID TCodes TValues1 OEL 4581 LEO 4581 SER 4582 LSE 583 LEO 633 OEL 63 |
|
Sachin.Nand
2937 Posts |
|
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2010-11-12 : 07:50:18
|
Thanks you sachin..but i dont want to parse values.. i want my comma seperated values in repeatative rowscan you please post query.. it will be more helpful to me..Thank again... |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-11-12 : 08:01:52
|
Then what is this?quote: I want to convert comma seperated values into rows.TID TCodes TValues1 OEL, LEO, SER 4582 LSE 583 LEO, OEL 63OUTPUTTID TCodes TValues1 OEL 4581 LEO 4581 SER 4582 LSE 583 LEO 633 OEL 63
PBUH |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
keyursoni85
Posting Yak Master
233 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-12-03 : 02:22:58
|
Another approach using xmldeclare @tab table(TID int identity(1,1),TCodes varchar(100),TValues int)insert into @tab(TCodes,TValues)select * from( values ('OEL,LEO,SER',458) ,('LSE',58) ,('LEO,OEL',63))t(TCodes,TValues) select t1.TValuesXML from @tab tcross apply( SELECT [TValuesXML]=s.i.value('local-name(.)','varchar(100)') FROM ( select TID, [TValuesXML]=CAST('<' + REPLACE(TCodes,',','/><') + '/>' AS XML) FROM @tab T1 ) T1 CROSS APPLY T1.TValuesXML.nodes('/*')s(i) WHERE T1.TID = t.TID)t1Iam a slow walker but i never walk back |
 |
|
|
|
|
|
|