通过传递脚本文件(.sql)作为参数来执行存储过程 [英] Execute stored procedure by passing the Script File(.sql) as Parameter
问题描述
我有一个存储过程,我在其中传递脚本文件(.sql
文件)作为参数.
I have a stored procedure, in wWhich I m passing the script file (.sql
file) as a parameter.
我想知道如何通过命令(不是命令提示符)执行 .sql
文件.
I want to know how .sql
file gets executed through command (not command prompt).
exec my_sp VersionNumber, SqlDeltaScript.sql (it is a file)
我希望我的存储过程执行 SqlDeltaScript.sql
I want my stored procedure to execute SqlDeltaScript.sql
任何人都可以帮忙解决这个问题吗...
Can anyone please help regarding this ...
提前致谢...
推荐答案
这听起来并不理想,但如果您必须这样做,那么您可以使用 xp_cmdshell 运行 sqlcmd 实用程序来运行您的脚本文件.
This does not sound like an ideal situation, but if you have to do this then you could use xp_cmdshell to run the sqlcmd utility to run your script file.
必须启用 xp_cmdshell SP 才能使用它 - 请参阅 启用 'xp_cmdshell' SQL Server.
The xp_cmdshell SP must be enabled in order ot use it - see Enable 'xp_cmdshell' SQL Server.
这篇关于通过传递脚本文件(.sql)作为参数来执行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!