Powershell SQLCMD
我们在使用 Powershell 和 SQLCMD 时遇到了问题,当 -v 参数变量中有空格时,powershell 将无法运行该命令。
例如,
sqlcmd ... -v VAR="Some space"
有人以前经历过这种情况或知道如何解决该问题吗?
谢谢,
B
We were experiencing problems with Powershell and SQLCMD, when there was sapces in the -v parameter variable powershell wouldn't run the command.
e.g.
sqlcmd ... -v VAR="Some space"
Has anyone experienced this before or know how to fix the problem?
Thanks,
B
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的语法适用于 PS 命令行,但在脚本中失败。
我们为如何完成这项工作奋斗了很长时间。 我们的一位非常聪明的 QA 人员最终想出了以下结论:
插头丑陋,但它有效。
The syntax above works for the PS commandline but fails within a script.
We struggled a long time with how to make this work. One of our very clever QA guys finally came up with the following:
Plug ugly but it works.
Powershell 实际上会将参数作为
"VAR=Some space"
传递给程序。 也许 sqlcmd 会偶然发现这一点。 通过使用,它将作为
VAR="Some space"
传递。 也许这可以解决问题。Powershell will actually pass the parameter to the program as
"VAR=Some space"
. Maybe sqlcmd stumbles over this. By usinginstead it will get passed as
VAR="Some space"
. Maybe that resolves the problem.