Invoke-SqlCmd and parameterised queries, with values containing an equals sign. How to properly escape?

Hi all,

I’m having an issue with trying to run in insert statement using parameters, and it seems to be related to a row containing an equals sign. ~24000 rows import without issue but two fail with the error: The format used to define the new variable for Invoke-Sqlcmd cmdlet is invalid. Please use the 'var=value' format for defining a new variable.

When I replace the equals sign with the string “EQUALS” it works without issue.

So my question is how do you properly escape the equals sign in this instance? Wrapping the string and escaping with a backtick both fail.

submitted by /u/Kamaroth
[link] [comments]

Leave a Reply