T-sql 脚本中 $(美元符号)的转义序列
问题描述:
我正在运行一个从 powershell 脚本调用的 T-SQL 脚本,其中包含一个文本行,其中包含一个包含 $(MV) 的序列.
I am running a T-SQL script, called from a powershell script, that contains a text row which includes a sequence containing $(MV).
当我运行脚本时,我收到错误'MV' 脚本变量未定义."我认为这是因为它将 $(MV) 字符串解释为变量而不是文本字符串的一部分.
When I run the script I get the error "'MV' scripting variable not defined." which I assume is because it interpretates the $(MV) string as a variable instead of being a part of the text string.
如何将美元符号写为转义序列?这可能在字符串中吗?
How can I write the dollar sign as an escape sequence? Is that possible in a string?
答
您可以在 PowerShell 中使用反引号字符来转义 $ 符号:
You can use the backtick character to escape a $ sign in PowerShell:
`$