应为它是主键! declare @a varchar(20) select @a=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('表名') and a.name='主鍵列名' and a.id=b.id and b.constid=c.id and c.name like 'PK%' exec('alter table 表名 drop constraint '+@a)
不允许对索引 'Table1.Tableindex1'显式地使用 DROP INDEX。该索引正用于 PRIMARY KEY 约束的强制执行。去掉主键
这是一个主键约束,不可显式地调用drop index,只能够使用: alter table Table1 drop constraint Tableindex1
select name from sysobjects where id =( select b.constid from sysobjects a join sysconstraints b on a.id=b.id where a.name='table') --找出主键alter table cloth3 drop CONSTRAINT PK_xx
谢谢各位 再问一句,要达到目的,到底用 alter table Table1 drop constraint Tableindex1 还是用 alter table Table1 drop Tableindex1 到底是删除约束,还是删掉索引?
它会自动生成一个聚簇索引,
你的index1可能就是它.
要先删除主键约束.用语句:alter table table1 drop constraint 约束名(如pk_???)
declare @a varchar(20)
select @a=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('表名') and a.name='主鍵列名' and a.id=b.id and b.constid=c.id and c.name like 'PK%'
exec('alter table 表名 drop constraint '+@a)
不允许对索引 'Table1.Tableindex1'显式地使用 DROP INDEX。该索引正用于 PRIMARY KEY 约束的强制执行。去掉主键
alter table Table1 drop constraint Tableindex1
select name from sysobjects
where id =(
select b.constid from sysobjects a join sysconstraints b on a.id=b.id
where a.name='table')
--找出主键alter table cloth3 drop CONSTRAINT PK_xx
再问一句,要达到目的,到底用
alter table Table1 drop constraint Tableindex1
还是用
alter table Table1 drop Tableindex1
到底是删除约束,还是删掉索引?