How to insert/copy rows from one table to another?

  • Hi,

    I am having a table with one column and 5 rows. i need to copy/insert these rows to another table with 2 columns in it.

    How would i do that with an efficient way?

    Ex:

    tbSource

    col

    ----

    5

    6

    7

    8

    9

    tbDestination

    col1 col2

    -------------

    Expected result should be

    tbDestination

    col1 col2

    ------------

    1 5

    1 6

    1 7

    1 8

    1 9

    Thanks.

  • Hi,

    The Sql code will be

    insert into tbDestination

    select 1,col from tbSource

  • descentflower (7/1/2009)


    How would i do that with an efficient way?

    Hi,

    What you mean the efficient way???

    create tbDestination

    (

    col1 int default as 1,

    col2 int

    )

    insert into tbDestination (Col2)

    select * from tbSource

    create tbDestination

    (

    col1 int ,

    col2 int

    )

    insert into tbDestination(1,Col2)

    select * from tbSource

    ARUN SAS

  • SELECT 1 'Col1',col 'Col2' INTO tbDestination FROM tbSource

  • Thanks for your help

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply