Insert Statement

  • How to insert the contents of a table into an empty table.

    I use the following syntax but the order has been changed.

    The order is not proper as tableX.

    insert into tableX

    select date, col1, col2, col3, col4, total

    from tableY

  • add the column name in insert statements...

    insert into tableX (date, col1, col2, col3, col4, total)

    select date, col1, col2, col3, col4, total

    from tableY

    hope it will help you..

    Cheers!

    Sandy.

    --

  • Thanks Sandy. It works.

  • One more thing, the total column shows NULL values as

    tableX has more columns then tableY.

  • Means???

    --

  • insert into tableX (date, col1, col2, col3, col4, total)

    select date, col1, col2, col3, col4, total

    from tableY

    tableX :

    date, col1, col2, col3, col4, col5, col6, total

    tableY :

    date, col1, col2, col3, col4, total

    the total column of tableX shows NULL values after executing the statement.

  • Sorry Sandy, it works properly. The total column has been changed with NULL values after i have executed a stored procedure which add a new row.

  • if your TableY-Total columns contains null or no values then only TableX Total column will contain the Null value...

    then whats wrong with that...??

    Cheers!

    Sandy..

    --

Viewing 8 posts - 1 through 7 (of 7 total)

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