Closed grothwell closed 1 month ago
thx for opening the issue! I suspect we only check -x after finding variable placeholders instead of skipping the variable scan altogether.
I did a quick local check and found DisableVariableSubstitution was being set to true when -x was present. The bug is likely in the implementation of how DisableVariableSubstitution is used. I did not trace it any further than that.
As far as I could tell there is no escape character for $(. My work around is to do character substitution in the script before running sqlcmd to avoid the error caused by sqlcmd finding $( in the sql script.
My actual case is a script that is inserting Javascript in the field of a table. I simplified the example in my issue report.
try 1.8
thx!
In go-sqlcmd 1.7.0 the -x parameter doesn't appear to be working and leads to an error. Running the same script using ODBC sqlcmd works properly.
testsql.sql contents:
SELECT '$('
Example command usage:
sqlcmd -i testsql.sql -x
Example output when not working:
Sqlcmd: Error: Syntax error at line 1