把多个条件串起来,传给存储过程报错
如:
create proc pr_name (@str varchar(1000))
as
exec('select * from tb '+@str)
exec pr_name ' where id=xx and name=xxx'
执行这句 引号里还有引号时报错!
------解决方案--------------------'' 2个引号作为转义
------解决方案--------------------SQL code
create proc pr_name
as
declare @sql varchar(1000)
set @sql='where id=xx and name=xxx'
select @sql='select * from tb'+@sql
exec(@sql)
exec pr_name
------解决方案--------------------
------解决方案--------------------