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

MSSQL 动态加载 SQL语句 (sp_executesql)

WBOY
Release: 2016-06-06 20:01:25
Original
1543 people have browsed it

--同时加载多个参数 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

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template