我要删除一个表的主键declare @cons varchar(100)
select @cons = name from sysobjects where xtype = 'pk' and parent_obj = object_id('table_1')
alter table [dbo.table_1] drop constraint @cons写完后执行 报错
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '@cons'.请帮忙看看哪里错了好吧 谢之
select @cons = name from sysobjects where xtype = 'pk' and parent_obj = object_id('table_1')
alter table [dbo.table_1] drop constraint @cons写完后执行 报错
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '@cons'.请帮忙看看哪里错了好吧 谢之
select @cons = name from sysobjects where xtype = 'pk' and parent_obj = object_id('table_1')
exec('alter table [table_1] drop constraint '+@cons+'')
declare @cons varchar(100)
select @cons = name from sysobjects where xtype = 'pk' and parent_obj = object_id('table_1')
alter table dbo.[table_1] drop constraint @cons