mssql 下删除 default 值的Sql写法
if exists (SELECT 1 FROM Sys.default_constraints a JOIN sys.columns b ON a.parent_object_id = b.object_id AND a.parent_column_id = b.column_id AND b.name = 'ISBNEnabled' where a.parent_object_id = OBJECT_ID('T_Kpa_eBayMonitor_Category') ) BEGIN declare @sysname nvarchar(1024) SELECT @sysname = a.name FROM Sys.default_constraints a JOIN sys.columns b ON a.parent_object_id = b.object_id AND a.parent_column_id = b.column_id AND b.name = 'ISBNEnabled' where a.parent_object_id = OBJECT_ID('T_ebayCategory') execute (' ALTER TABLE T_eBayCategory DROP Constraint '+ @sysname ) END