Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Watch out: change for line numbers in SSMS 2014 Expand / Collapse
Posted Tuesday, April 22, 2014 2:48 PM

SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, August 21, 2014 3:04 PM
Points: 801, Visits: 715
There is a change in SSMS 2014 how line numbers are displayed in error messages. Instead of displaying the raw line number from SQL Server, SSMS 2014 adds the offset where the current batch starts to the error message. So if the query window reads:

PRINT 'This is the first batch'
PRINT 'This is the second batch'
PRINT 'This is a the third batch' 'and it has a syntax error'

The output message in SSMS 2014 is:

This is the first batch
This is the second batch
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'and it has a syntax error'.

SSMS 2012 reports the error to be on line 1. You could argue that this is midly useful. However, there is a very nasty side effect. Consider:

CREATE TABLE PoorLittleNemo (a tinyint NOT NULL)
CREATE PROCEDURE ScenesFromANightsDream @a int AS
INSERT PoorLittleNemo(a) VALUES (@a)
EXEC ScenesFromANightsDream 800
DROP TABLE PoorLittleNemo
DROP PROCEDURE ScenesFromANightsDream

The output in SSMS 2014 is:

Msg 220, Level 16, State 2, Procedure ScenesFromANightsDream, Line 7
Arithmetic overflow error for data type tinyint, value = 800.
The statement has been terminated.

There are not seven lines in that stored procedure!

I find this extremely unhelpful, If I get an error from a stored procedure that I run from my query window (which often is a scratchpad of various ad hoc statements), I need to find where the current batch starts (Typically I only select a single statement) to compute the correct line number. And if I get the message from a co-worker, I have no idea how his query window looked like.

I have submitted a Connect item on

If you feel the same as me, vote up!
If you think this is a great improvement, vote down!
If you don't care - don't vote at all.

Erland Sommarskog, SQL Server MVP,
Post #1564042
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse