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

后端 未结 30 2228
轮回少年
轮回少年 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:24

    This can be done in the SSMS GUI as well. I show a default date below but the default value can be whatever, of course.

    1. Put your table in design view (Right click on the table in object explorer->Design)
    2. Add a column to the table (or click on the column you want to update if it already exists)
    3. In Column Properties below, enter (getdate()) or 'abc' or 0 or whatever value you want in Default Value or Binding field as pictured below:

提交回复
热议问题