Creating SQL Script

  • Hi All,

    I want to create a SQL Script in SQL 2000 for the existing table.

    my script will do the followings:

    1. It will add two new columns on the existing table.

    2. It will copy the existing column1 data to the newly created columns

    i am new to SQL Server 2000 .

    so any one please help me to write the script?

    thanks.

    With Regards,

    Anbaz.

  • Hello,

    1) Use the Alter Table statement to add the new columns. This is the example given in BOL (Books Online):-

    ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL

    GO

    2) Use an Update statement to copy the data across. Something like:-

    Update MyTable Set NewColumn = Column1

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

Viewing 2 posts - 1 through 1 (of 1 total)

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