使用Sp_executesql [英] Use of Sp_executesql
本文介绍了使用Sp_executesql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以解释一下sql server中Sp_executesql的用途。
提前谢谢。
Can any one explain what is the use of Sp_executesql in sql server.
Thanks in advance.
推荐答案
看看这些文章,
https://msdn.microsoft.com/en-IN /library/ms188001.aspx [ ^ ]
http://www.mssqltips.com/sqlservertip/1160/execute-dynamic-sql-commands-in-sql-server/ [ ^ ]
http://www.sqlskills.com / blogs / kimberly / exec-and-sp_executesql-how-are-they-different / [ ^ ]
http://blogs.msdn.com/b/turgays/archive/2013/09/18/exec-vs-sp-executesql.aspx [ ^ ]
编辑:链接破碎
Have a look at these articles,
https://msdn.microsoft.com/en-IN/library/ms188001.aspx[^]
http://www.mssqltips.com/sqlservertip/1160/execute-dynamic-sql-commands-in-sql-server/[^]
http://www.sqlskills.com/blogs/kimberly/exec-and-sp_executesql-how-are-they-different/[^]
http://blogs.msdn.com/b/turgays/archive/2013/09/18/exec-vs-sp-executesql.aspx[^]
Edited: Links Broken
使用Sp_executesql
?
*。支持参数替换。
*。拒绝执行计划。
https://technet.microsoft.com/en-us/library/ms175170%28v=sql.105%29.aspx [ ^ ]
执行可多次重用的Transact-SQL语句或批处理,或者已动态构建的语句或批处理。 Transact-SQL语句或批处理可以包含嵌入的参数。
示例
声明@SQLstring nvarchar( 500)= '选择GETDATE()'
DECLARE @parmdefination navarchar(500);
EXEC sp_executesql的@SQLString,@ParmDefinition <无线电通信/>
它将返回当前日期时间..
与我们可以运行存储过程相同。
希望这对你有帮助。
Executes a Transact-SQL statement or batch that can be reused many times, or one that has been built dynamically. The Transact-SQL statement or batch can contain embedded parameters.
example
declare @SQLstring nvarchar (500) = 'select getdate()'
declare @parmdefination navarchar(500);
exec sp_executesql @SQLString, @ParmDefinition
it will return current date time..
same as we can run stored procedure.
hope this will help you.
这篇关于使用Sp_executesql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文