July 17, 2012 at 6:01 am
i want to split one column into multiple till the last delimiter ends. Delimiter is comma
July 17, 2012 at 6:08 am
When you think of split, always remember Jeff's code....:-)
July 18, 2012 at 5:19 am
July 18, 2012 at 11:37 pm
Pls chk this code...
declare @testtable table (id int, date varchar(max))
declare @testtable1 table (id int, date1 varchar(max))
declare @date1 varchar(max)
declare @i int =1
insert into @testtable values(1,'2011-09-08,2012-09-07')
insert into @testtable values(2,'2011-05-07,2012-07-10,2012-03-14')
insert into @testtable values(3,'2011-12-09,2012-03-14')
insert into @testtable values(4,'2011-01-04,2012-11-11')
while(@i<= (Select max(id) from @testtable))
begin
select @date1 = DATE from @testtable where id =@i
insert into @testtable1(id,date1)
Select @i,val FROM dbo.Split(@date1,',')
Set @i+=1
end
Select * from @testtable1
Thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply