Skip to content

go-sqlcmd reports incorrect line numbers (because it strips blank lines) #395

@sommarskog

Description

@sommarskog

slask.txt
If you attempt to load the attached file in the Northwind database, you will get this error:

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

If you account for the initial batch, you add 2 to 34 and you to line 36 in file to look at:

      JOIN   Products P ON P.ProductID = OD.ProductID

and you ask yourself, what's wrong with that?

Answer: absolutely nothing. But if you move to line 41 in the file, you find:

   IF @debug == 1

And that is not legal T-SQL.

If you remove the extraneous = and load the file again, it succeeds. If you run

sp_helptext ProductCountrSales_sp

You find why the line number was not reported correctly; All blank lines have been stripped out.

Lest you think this is a very small thing, it is not. This is a complete show-stopper for me to start using go-sqlcmd. I use SQLCMD to load stored procedures from my Editor, and having correct line numbers is absolutely essential.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions