Open jtougas opened 4 years ago
I'm having trouble declaring a variable and a cte in one statement. This is something that works with sqlcmd.
sqlcmd
Statement
STMT=$(cat <<'EOF' DECLARE @bar INT = 1 ;with foo as (select @bar as foo) select * from foo GO EOF )
$ sqlcmd -S sqlserver.corp.com -U username -P password -Q "${STMT}" foo ----------- 1 (1 rows affected)
mssql-cli
$ mssql-cli --username username --password password --server sqlserver.corp.com --query "${STMT}" Commands completed successfully. Msg 137, Level 15, State 2, Line 2 Must declare the scalar variable "@bar".
I've repro'd the bug on my end. mssql-cli is able to print the scalar value as long as it's not referenced in a CTE.
Thank you @jtougas for letting us know about this bug!
I'm having trouble declaring a variable and a cte in one statement. This is something that works with
sqlcmd
.Statement
sqlcmd
mssql-cli