Home Forums SQL Server 2008 T-SQL (SS2K8) Importing only rows with column data in specific columns. RE: Importing only rows with column data in specific columns.

  • Nope, more like this:

    with basedata (

    name,

    addy,

    ph,

    grade

    ) as (

    select

    name,

    addy,

    ph,

    grade1

    from

    sourcetable

    union all

    select

    name,

    addy,

    ph,

    grade2

    from

    sourcetable

    union all

    select

    name,

    addy,

    ph,

    grade3

    from

    sourcetable

    union all

    select

    name,

    addy,

    ph,

    grade4

    from

    sourcetable

    union all

    select

    name,

    addy,

    ph,

    grade5

    from

    sourcetable

    )

    INSERT INTO dest_table(

    name,

    addy,

    ph,

    grade

    )

    select

    name,

    addy,

    ph,

    grade

    from

    BaseData

    where

    grade is not null;