首页 >php教程 >php手册 >MSSQL 动态加载 SQL语句 (sp_executesql)

MSSQL 动态加载 SQL语句 (sp_executesql)

WBOY
WBOY原创
2016-06-06 20:01:251540浏览

--同时加载多个参数 declare @aa nvarchar(40) declare @min_lvl tinyint execute sp_executesql N'select job_desc,min_lvl from jobs where job_id=6',N'@aa nvarchar(40) output,@min_lvl tinyint output' ,@aa output,@min_lvl output print @aa print @

 

 --同时加载多个参数

declare @aa nvarchar(40)
declare @min_lvl tinyint
execute sp_executesql N'select job_desc,min_lvl from jobs where job_id=6',N'@aa nvarchar(40) output,@min_lvl tinyint output' ,@aa output,@min_lvl output
print @aa
print @min_lvl

 

 

---------------------------------------------------------------------

 

--只能加载一个参数

declare @aa nvarchar(40)
execute sp_executesql N'select @aa=job_desc from jobs where job_id=6',N'@aa nvarchar(40) output',@aa output select @aa

 

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn