我需要将一列的数据类型从smallint更改为bigint(设计考虑较差,不要问)。我运行TSQL
alter table dbo.Test alter column ProductionModeID bigint NULL
但是得到消息:
Msg 5074, Level 16, State 1, Line 1 The object 'DF_Test_ProductionModeID' is dependent on column 'ProductionModeID'.
Msg 4922, Level 16, State 9, Line 1 ALTER TABLE ALTER COLUMN ProductionModeID failed because one or more objects access this column.
我在dbo.Test >>约束中找到了
DF_Test_ProductionModeID
。 (我不知道DF_Test_ProductionModeID
是如何创建的,也不知道我需要它的存在)。我按Delete键,选择“确定”按钮,并收到以下消息:===================================
The Default 'DF_Test_ProductionModeID' does not exist on the server. (SqlManagerUI)
Program Location:
at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DoDropObject(Int32 objectRowIndex) at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DropAllObjects(Boolean stopOnError)
所以我现在很困惑,因为如果它不存在,那么它如何依赖列呢?
最佳答案
运行以下命令会发生什么?
ALTER table Test drop DF_Test_ProductionModeID
另请参阅How To Name Default Constraints And How To Drop Default Constraint Without A Name In SQL Server以获取更多信息
关于sql-server-2008 - 尝试删除默认值,但收到一条消息,提示它在服务器上不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15260951/