查找指定表的字段not null约束,并生成删除Sql

SElECT 'ALTER TABLE '+OBJECT_NAME(c.parent_obj)+'  DROP CONSTRAINT '+ c.name 
FROM sys.sysconstraints a,sys.columns b,sys.sysobjects c 
   WHERE 
     a.colid = b.column_id AND a.id = b.object_id AND  
    b.name in ('upc','ean','isbn') AND c.type = 'D' AND c.id = a.constid
    

  

原文地址:https://www.cnblogs.com/starluck/p/4682414.html