April 14, 2013 at 10:06 am
Hi..
I Want to Spliting the Data for The Following Table. Using The Stored Procedure....
Create Table Source (Owner_Name varchar(100),SeatNo Varchar(100))
insert into Source values ('A','10,11,12'),('B','20,21,22'),('C','30,31,32')
select * from source
A10,11,12
B20,21,22
C30,31,32
But My Requirement Structure Sholud like below Mentioned..
NameNo
A10
A11
A12
B20
B21
B22
C30
C31
C32
Thanks & Regards,
K.D.Saravanan
April 14, 2013 at 11:40 am
You need to apply a good splitter to each CSV. Like this.
SELECT s.Owner_Name,
SeatNo = split.Item
FROM dbo.Source s
CROSS APPLY dbo.DelimitedSplit8K(s.SeatNo,',') split
;
You can get the DelimitedSplit8K splitter from the following article which also explains why you shouldn't use other types of splitters.
http://www.sqlservercentral.com/articles/Tally+Table/72993/
--Jeff Moden
Change is inevitable... Change for the better is not.
April 14, 2013 at 11:58 am
Thank you sir...
Thank you so much....
Take Care...
Regards,
K.D.Saravanan
April 14, 2013 at 1:05 pm
sarwaanmca (4/14/2013)
Thank you sir...Thank you so much....
Take Care...
Regards,
K.D.Saravanan
Thank you for the feedback. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply