Help Needed in Split Column

  • i want to split one column into multiple till the last delimiter ends. Delimiter is comma

  • When you think of split, always remember Jeff's code....:-)

    http://www.sqlservercentral.com/articles/Tally+Table/72993/

  • Use the Splitter as a function and Cross Apply on the Table to get the desired results. Post DDL and Sample data for a working example.

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • 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