"致命脚本错误:不支持命令输出"在PostDeployment脚本中

时间:2016-01-22 10:09:28

标签: sql sql-server sqlcmd database-project

在我的数据库项目中,我有Post-Deployment脚本,如下所示:

:r "..\PostDeployment\InitialScript1.sql"
:r "..\PostDeployment\InitialScript2.sql"
:r "..\PostDeployment\InitialScript3.sql"

它运行良好并成功调用所需的脚本。

但是我在SQL Server上有一个表,其中包含需要在部署期间执行并且只执行一次的其他脚本的列表。所以我想在我的Post-Deployment脚本中添加下一个代码

:out "..\PostDeployment\RunAdditionalScripts.sql"
SELECT N':r "..\PostDeployment\SingleScripts\' + ste.Script_Name + '"
UPDATE ScriptsToExec SET IsExecuted = 1 WHERE Script_Name = ''' + ste.Script_Name + '''' 
FROM ScriptsToExec AS ste WHERE ste.IsExecuted = 0
:r "..\PostDeployment\RunAdditionalScripts.sql"

我希望,我会生成一个带有下一个代码的文件RunAdditionalScripts.sql

:r "..\PostDeployment\SingleScripts\AdditionalScript1.sql"
UPDATE ScriptsToExec SET IsExecuted = 1 WHERE Script_Name = 'AdditionalScript1.sql' 
:r "..\PostDeployment\SingleScripts\AdditionalScript2.sql"
UPDATE ScriptsToExec SET IsExecuted = 1 WHERE Script_Name = 'AdditionalScript2.sql' 
:r "..\PostDeployment\SingleScripts\AdditionalScript3.sql"
UPDATE ScriptsToExec SET IsExecuted = 1 WHERE Script_Name = 'AdditionalScript3.sql' 

但是,当我试图添加:out命令时,我收到错误"致命脚本错误:不支持命令输出" (SQLCMD模式已打开)。那么,我怎样才能完成这项工作或如何实现我的目标呢?

0 个答案:

没有答案