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

    col1col2

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

    Expected result should be

    tbDestination

    col1col2

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

    15

    16

    17

    18

    19

    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