Home Forums SQL Server 2005 SQL Server Newbies Generate two columns from single column with alternating data RE: Generate two columns from single column with alternating data

  • Provided the date rows are always valid dates and follow a row with a name, there is this solution:

    create table #test (Id int, Value varchar(25))

    insert into #test

    select 1, 'John Smith'

    union select 2, '9/13/1961'

    union select 3, 'Phony Persson'

    union select 4, '2/24/1943'

    union select 5, 'Doc Galacawicz'

    union select 6, '11/11/1999'

    SELECT a.Value, b.Value

    FROM #test a INNER JOIN #test b on a.Id = b.Id - 1

    AND ISDATE(b.Value) = 1

    WHERE ISDATE(a.Value) = 0

    ORDER BY a.Id