Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Watch out: change for line numbers in SSMS 2014

$
0
0
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:[code="sql"]PRINT 'This is the first batch'goPRINT 'This is the second batch'goPRINT 'This is a the third batch' 'and it has a syntax error'[/code]The output message in SSMS 2014 is:[code="plain"]This is the first batchThis is the second batchMsg 102, Level 15, State 1, Line 5Incorrect syntax near 'and it has a syntax error'.[/code]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:[code="sql"]CREATE TABLE PoorLittleNemo (a tinyint NOT NULL)goCREATE PROCEDURE ScenesFromANightsDream @a int AS INSERT PoorLittleNemo(a) VALUES (@a)goEXEC ScenesFromANightsDream 800goDROP TABLE PoorLittleNemoDROP PROCEDURE ScenesFromANightsDream[/code]The output in SSMS 2014 is:[code="plain"]Msg 220, Level 16, State 2, Procedure ScenesFromANightsDream, Line 7Arithmetic overflow error for data type tinyint, value = 800.The statement has been terminated.[/code]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 [url=https://connect.microsoft.com/SQLServer/feedback/details/857794/ssms-reports-incorrect-line-number-for-error-that-occurs-in-stored-procedures]https://connect.microsoft.com/SQLServer/feedback/details/857794/ssms-reports-incorrect-line-number-for-error-that-occurs-in-stored-procedures[/url]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.

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images