我正在使用 sqlpackage.exe 部署 dacpac,并且需要为 dacpac 中的部署后脚本传递 SqlCMD 变量。我发现了一个相关问题here https://stackoverflow.com/questions/15502659/what-is-the-syntax-for-adding-multiple-arguments-onto-the-variables-parameter and here https://social.msdn.microsoft.com/Forums/sqlserver/en-US/87cd1fb1-9f63-4c60-a0af-56ade87a6f0d/specifing-sqlcmd-variable-values-when-using-sqlpackageexe?forum=ssdt.
但我收到以下错误:以下 SqlCmd 变量缺少值:BuildVersion 描述。
Description=$Description :术语“Description=$Description”不是
被识别为 cmdlet、函数、脚本文件或可操作的名称
程序。检查名称的拼写,或者如果包含路径,请验证
确认路径正确,然后重试。
请帮我。
将 SQLCMD 变量传递给 SQLPackage 的正确开关如下所示
/v:描述=$描述
Powershell 引用有点棘手。
这是一个供您参考的示例:
https://gist.github.com/davoscollective/adf9b890984e51d8dee2 https://gist.github.com/davoscollective/adf9b890984e51d8dee2
& "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe" ` #Note this is SQL Server 2012 specific directory, alter as needed
/Action:Publish `
/SourceFile:$sourceFile `
/TargetServerName:$targetServerName `
/TargetDatabaseName:$targetDBname `
/V:SQLCMDVariable1=$SQLCMDVariable1 ` #If your project includes other database references, or pre/post deployment scripts uses SQLCMD variables
/v:SQLCMDVariable2=$SQLCMDVariable2 `
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)