Declare @chr1 nvarchar(100) Declare @chrSql nvarchar(1000)Select @chr1=[Name] from sysobjects where xtype='PK' and Parent_Obj In(Select [Id] from sysObjects where [name]='表名') Set @chrsql='Alter Table 表名 drop CONSTRAINT ' + @chr1 Select @chrsql execute( @chrsql)这是删除一个表主索引(主键)所需要的Sql语句在打开表之前,先用conn.execute以上语句就可以了
Declare @chrSql nvarchar(1000)Select @chr1=[Name] from sysobjects where xtype='PK' and Parent_Obj In(Select [Id] from sysObjects where [name]='表名')
Set @chrsql='Alter Table 表名 drop CONSTRAINT ' + @chr1
Select @chrsql
execute( @chrsql)这是删除一个表主索引(主键)所需要的Sql语句在打开表之前,先用conn.execute以上语句就可以了