select * from sysconstraints where id=object_id('表名')
drop constraint 约束名
go
sysconstraints
包含约束映射,映射到拥有该约束的对象。该系统目录存储在每个数据库中。
列名 数据类型 描述
constid int 约束号。
id int 拥有该约束的表 ID。
colid smallint 在其上定义约束的列 ID,如果是表约束则为 0。
spare1 tinyint 保留。
status int 位图指示状态。可能的值包括:
1 = PRIMARY KEY 约束。
2 = UNIQUE KEY 约束。
3 = FOREIGN KEY 约束。
4 = CHECK 约束。
5 = DEFAULT 约束。
16 = 列级约束。
32 = 表级约束。
actions int 保留。
error int 保留。
很奇怪的方法
請試用:
select * into #temp from 表名
drop table 表名
select * into 表名 from #temp
drop table temp
drop constraint 约束名
go
sysconstraints
包含约束映射,映射到拥有该约束的对象。该系统目录存储在每个数据库中。
列名 数据类型 描述
constid int 约束号。
id int 拥有该约束的表 ID。
colid smallint 在其上定义约束的列 ID,如果是表约束则为 0。
spare1 tinyint 保留。
status int 位图指示状态。可能的值包括:
1 = PRIMARY KEY 约束。
2 = UNIQUE KEY 约束。
3 = FOREIGN KEY 约束。
4 = CHECK 约束。
5 = DEFAULT 约束。
16 = 列级约束。
32 = 表级约束。
actions int 保留。
error int 保留。
很奇怪的方法
請試用:
select * into #temp from 表名
drop table 表名
select * into 表名 from #temp
drop table temp