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

EXIT command not parsed in powershell using -Q #520

Open amafernandes opened 2 months ago

amafernandes commented 2 months ago

In go-sqlcmd 1.6.0 the powershell script bellow, produces and error, this is output of variable $result:

Msg 102, Level 15, State 1, Server ., Line 4 Incorrect syntax near ':'.

Running the same script using ODBC sqlcmd works properly.

$result = sqlcmd -b -X1 -E -W -h -1 -Q "
Select 2;

:EXIT(SELECT 200)"

echo $LASTEXITCODE
echo $result