How to set a default value for an existing column
This isn't working in SQL Server 2008:
ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES'
The error is:
Incorrect syntax near the keyword 'SET'.
What am I doing wrong?
这将在SQL Server中工作:
ALTER TABLE Employee ADD CONSTRAINT DF_SomeName DEFAULT N'SANDNES' FOR CityBorn;
ALTER TABLE Employee ADD DEFAULT 'SANDNES' FOR CityBorn
不能使用alter列,而是使用add
ALTER TABLE Employee
ADD DEFAULT('SANDNES') FOR CityBorn
链接地址: http://www.djcxy.com/p/24706.html
上一篇: 在SQL Server中将日期时间字段的默认值添加到时间戳
下一篇: 如何为现有列设置默认值