sql-server-2008 - 尝试删除默认值,但收到一条消息,提示它在服务器上不存在

标签 sql-server-2008 tsql constraints

我需要将一列的数据类型从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)


For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+((KJ_RTM).100213-0103+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.ObjectDoesNotExist&LinkId=20476


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/

相关文章:

sql - 在 SQL 中对重复的行进行分组

swift - 未遵守程序约束

sql - SQL Server 2008 中的 BIDS、标准版和企业版

sql - T-SQL : Use t-sql while routine return value in SELECT

c# - Linq DataContext SubmitChanges InvalidOperationException from ZombieCheck

c# - 为什么 SQL Server 数据库用户写入错误的架构?

sql - 如果存储过程中的参数为null,则不更新列

sql - 递归查询列中的 anchor 和递归部分之间的类型不匹配

ios - 如何根据 iPhone 尺寸在 Splash 中设置不同的约束?

ios - 以编程方式将指示器 View 置于警报 Controller 中