microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
323 stars 56 forks source link

Double exclamation within text expression with some parenthesis deal as sqlcmd instruction #514

Closed AndreyShvidky closed 2 months ago

AndreyShvidky commented 3 months ago

Got script with such an expression (sorry, but Code applet eats carriage returns)

print ('Some text !! Some more text')

SQLCMD version 1.6.0 gives error "Some" is not recognized as an internal or external command, operable program or batch file. Msg 105, Level 15, State 1, Server SRV, Line 1 Unclosed quotation mark after the character string "Some text". Msg 102, Level 15, State 1, Server SRV, Line 1 Incorrect syntax near "Some text".

I found it in

raiserror ('Some text !! Some more text', 10, 0)

Nevertheless

print 'Some text !! Some more text'

works fine.

So the problem not just in two exclamations in new line, but using parenthesis as well.

Previous versions works fine (I mean old SDK versions installed with SQL server or other way in C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn).