SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Watch out: change for line numbers in SSMS 2014


Watch out: change for line numbers in SSMS 2014

Author
Message
Erland Sommarskog
Erland Sommarskog
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2115 Visits: 872
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'
go
PRINT 'This is the second batch'
go
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)
go
CREATE PROCEDURE ScenesFromANightsDream @a int AS
INSERT PoorLittleNemo(a) VALUES (@a)
go
EXEC ScenesFromANightsDream 800
go
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
https://connect.microsoft.com/SQLServer/feedback/details/857794/ssms-reports-incorrect-line-number-for-error-that-occurs-in-stored-procedures

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, www.sommarskog.se
i_amhers
i_amhers
SSC Journeyman
SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)SSC Journeyman (82 reputation)

Group: General Forum Members
Points: 82 Visits: 108
Hey There!!


SSMS 12/14 are operating the same way at the lower level.

The last example shows this perfectly. There are that many lines ( albeit they aren't shown ) Think about what SSMS is doing behind the scenes, right ? That is REALLY helpful, because now you are able to find out that your recursive task failed the xth time into the code.

I think I understand that challenge though, when you are anticipating the lower count for "physical" lines. But correct me if I am wrong; but I could have sworn the execution plans are operating the exact same way- thus this is a cosmetic change that is letting us see more information than previously provided.

Thoughts?
Jeremy
Eirikur Eiriksson
Eirikur Eiriksson
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15144 Visits: 18599
+1

This is very annoying to say the least, hope it gets corrected!
Cool
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search