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
343 stars 60 forks source link

go-sqlcmd does not report procedure name #396

Closed sommarskog closed 1 year ago

sommarskog commented 1 year ago

slask.txt If you attempt to load the attached file in the Northwind database with go-sqlcmd, you get this output:

Changed database context to 'Northwind'.
Msg 102, Level 15, State 1, Server SERVERNAME, Line 34
Incorrect syntax near '='.

If you instead attempt to load it with old SQLCMD, you see this:

Changed database context to 'Northwind'.
Msg 102, Level 15, State 1, Server SERVERNAME, Procedure ProductCountrSales_sp, Line 39
Incorrect syntax near '='.

The difference is that the message from old SQLCMD includes the name of the stored procedure, but this is missing from go-sqlcmd. In this particular case, this is not a big deal, but imagine that if the file includes many stored procedures and other objects. Not knowing in which procedure the syntax error is hiding, is certainly problematic.