Add 2 columns in one sql statement

  • Hi

    I want to add 2 columns to the existing table. How to do it?

    I m using below query but getting error as given below. I m using sql server 2005

    ALTER TABLE Transactionlog

    ADD ( businessunit_id numeric(10,0),

    businessunit_name varchar(250) );

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

    ERROR

    Msg 102, Level 15, State 1, Line 4

    Incorrect syntax near '('.

  • Sachin, remove the "( )" from your code ;

    Sample code:

    create table #temp1

    (

    a int

    )

    select * From #temp1

    alter table #temp1 add b int , c int ;

    select * from #temp1

  • Change it like this

    ALTER TABLE Transactionlog

    ADD businessunit_id NUMERIC(10,0), businessunit_name VARCHAR(250)


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Thank u coldcoffee and kingston

    It worked fine. Such a simple mistake 🙂

    Thank u both

    sachin

  • You're welcome buddy 🙂

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

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