22,209
社区成员
发帖
与我相关
我的任务
分享
create table tb(id int,col nvarchar(20))
insert into tb select 1,'aaaa' union select 2,'bbbb' union select 3,'cccc'
go
create proc p_test
@tbl nvarchar(40),
@field nvarchar(40),
@value nvarchar(40)
as
declare @sql nvarchar(4000)
set @sql='delete from '+@tbl+' where '+@field+'='''+@value+''''
exec(@sql)
go
exec p_test 'tb','col','bbbb'
select * from tb
go
drop proc p_test
drop table tb
/*
id col
----------- --------------------
1 aaaa
3 cccc
(2 行受影响)
*/