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

 

posted @ 2016-06-16 09:30  不能失败  阅读(322)  评论(0编辑  收藏  举报