Add a column with a default value to an existing table in SQL Server

后端 未结 30 2819
轮回少年
轮回少年 2020-11-22 12:00

How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005?

30条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 12:14

    If you want to add multiple columns you can do it this way for example:

    ALTER TABLE YourTable
        ADD Column1 INT NOT NULL DEFAULT 0,
            Column2 INT NOT NULL DEFAULT 1,
            Column3 VARCHAR(50) DEFAULT 'Hello'
    GO
    

提交回复
热议问题