sqlserver中如何判断一个约束是否存在?

IF  EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_约束名]') AND parent_object_id = OBJECT_ID(N'[dbo].[表名]'))
ALTER TABLE [dbo].[表名] DROP CONSTRAINT [CK_约束名]
 
 
sqlserver中如何判断一个表是否存在?
 
 
 if exists(select * from sys.objects where object_id=object_id(N'表名'))
 drop table 表名

你可能感兴趣的:(SQL,SERVER,2005)