我正在玩Powershell并插入查询。
现在我有一个Query,它会在我的列中插入一些XML语法。
由于Query语法的开头如下:
$SqlQuery = "Insert into..." and as well ends with double quotes I have trouble to insert something which already uses double quotes.
我需要插入这个: div class =“list tipGreen”
我的错误是:Unexpected token 'list' in expression or statement...
有人可以给我一个提示,如何避免这种语法问题?
答案 0 :(得分:3)
使用here-strings
$SqlQuery = @"
div class="list tipGreen"
"@
请参阅帮助about_Quoting_Rules
答案 1 :(得分:0)
请改用单引号。
$SqlQuery = 'INSERT INTO table SELECT ''' + text/variableWithSingleQuotesAroundIt + '''
或
$SqlQuery = 'INSERT INTO table SELECT ' + text/variableWithNoQuotesAroundIt + '