动态sql语句传参数 怎么将sql语句查询的结果作为参数传递给存储过程?
怎么将sql语句查询的结果作为参数传递给存储过程?将SQL语句作为参数传到存储过程,请参见一下示例:-- 创建示范存储过程create procedure mypro1(@strSql nvarcha
怎么将sql语句查询的结果作为参数传递给存储过程?
将SQL语句作为参数传到存储过程,请参见一下示例:-- 创建示范存储过程create procedure mypro1(@strSql nvarchar(4000))asexecute sp_executesql @strsqlgo-- 创建示范表并插入数据create table test1 (id int primary key,name nvarchar(50))insert into test1 values(100,"Johnson")-- 将SQL语句作为参数在存储过程里执行execute mypro1 "select * from test1"-- 删除示范对象drop table test1drop procedure mypro1