From: mat on
In SSMS (2008) the line that an error is reported on has basically
nothing to do with the line the error is on in the sql editor window.
The error is reported on some idealized line number skipping whitespace
and who knows what else. So while the error is reported on line 15, it's
on line 24 in the sql editor, where I need to fix it. There is no
pointer to line 24 that I can find...if I select Edit Go To line 15, it
goes to line 15 in the editor, not line 15 in the sql (according to
whatever standards it uses to compute a line of SQL).

It's a very annoying aspect of SSMS. I want to know on what line in the
editor the error is on. There must be a simple workaround for this?

Why would Microsoft has the error reported in such a useless manner
after so many editions of SSMS? So far I've not found anything on this
by googling but maybe...
From: yssr83 on
Firstly the error line number depends on how you select the code and
run it, like you have ten lines and you select the 10th line and
execute it and and if there is an error, it would show the error to be
in Line 1.

And the other thing is when you are using try catch blocks. mostly if
you use the raise error that would go to a try catch block.

Yes, the one thing is if you ever find an error, look for it in the
lines above then reported...

Sriram
www.sqllike.com


On Dec 6, 6:03 am, mat <m...(a)notarealdotcom.adr> wrote:
> In SSMS (2008) the line that an error is reported on has basically
> nothing to do with the line the error is on in the sql editor window.
> The error is reported on some idealized line number skipping whitespace
> and who knows what else. So while the error is reported on line 15, it's
> on line 24 in the sql editor, where I need to fix it. There is no
> pointer to line 24 that I can find...if I select Edit Go To line 15, it
> goes to line 15 in the editor, not line 15 in the sql (according to
> whatever standards it uses to compute a line of SQL).
>
> It's a very annoying aspect of SSMS. I want to know on what line in the
> editor the error is on. There must be a simple workaround for this?
>
> Why would Microsoft has the error reported in such a useless manner
> after so many editions of SSMS? So far I've not found anything on this
> by googling but maybe...

From: Mike John on
Double clicking on the error message jumps the edit window to the line that
the error was reported on. Depending on the nature of the error the cause
may be earlier of course, but it gets you pretty close.

Mike

"mat" <mat(a)notarealdotcom.adr> wrote in message
news:MPG.2584a2afb4d89565989799(a)msnews.microsoft.com...
> In SSMS (2008) the line that an error is reported on has basically
> nothing to do with the line the error is on in the sql editor window.
> The error is reported on some idealized line number skipping whitespace
> and who knows what else. So while the error is reported on line 15, it's
> on line 24 in the sql editor, where I need to fix it. There is no
> pointer to line 24 that I can find...if I select Edit Go To line 15, it
> goes to line 15 in the editor, not line 15 in the sql (according to
> whatever standards it uses to compute a line of SQL).
>
> It's a very annoying aspect of SSMS. I want to know on what line in the
> editor the error is on. There must be a simple workaround for this?
>
> Why would Microsoft has the error reported in such a useless manner
> after so many editions of SSMS? So far I've not found anything on this
> by googling but maybe...

From: Erland Sommarskog on
mat (mat(a)notarealdotcom.adr) writes:
> In SSMS (2008) the line that an error is reported on has basically
> nothing to do with the line the error is on in the sql editor window.
> The error is reported on some idealized line number skipping whitespace
> and who knows what else. So while the error is reported on line 15, it's
> on line 24 in the sql editor, where I need to fix it. There is no
> pointer to line 24 that I can find...if I select Edit Go To line 15, it
> goes to line 15 in the editor, not line 15 in the sql (according to
> whatever standards it uses to compute a line of SQL).
>
> It's a very annoying aspect of SSMS. I want to know on what line in the
> editor the error is on. There must be a simple workaround for this?
>
> Why would Microsoft has the error reported in such a useless manner
> after so many editions of SSMS? So far I've not found anything on this
> by googling but maybe...

You need to keep in mind that there are two applications here: SQL
Server and SSMS. SQL Server reports error number in its context, and
SSMS displays them unchanged. SQL Server does not know about your
editor window, it only knows about the batches sent to it.

Now, in most cases this is easy: you just double-click on an error message
and SSMS will take you to that line, because SSMS is able to correlate
the line SQL Server reporter, with the line in the editor window.

However, this only works out if the error is in the top-most scope.
If the error occurs in a batch of dynamic SQL invoked by sp_executesql
or EXEC(), or in a stored procedure, the error number no longer has
any relation to the query window at all. In this situation, you need
to look at the code for the procedure, or debug output of the dynamic
SQL.

And, yeah, SQL Server is not very accurate when it reports the line
numbers. It has gone better, but there are still situations where
it will point to the first line of a 50-line statement, telling you
that there is an non-existent column.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: mat on
OK, thanks for the tip.

In article <O3CGUqldKHA.2460(a)TK2MSFTNGP04.phx.gbl>, a(a)a.com says...
> Double clicking on the error message jumps the edit window to the line that
> the error was reported on. Depending on the nature of the error the cause
> may be earlier of course, but it gets you pretty close.
>
> Mike
>
> "mat" <mat(a)notarealdotcom.adr> wrote in message
> news:MPG.2584a2afb4d89565989799(a)msnews.microsoft.com...
> > In SSMS (2008) the line that an error is reported on has basically
> > nothing to do with the line the error is on in the sql editor window.
> > The error is reported on some idealized line number skipping whitespace
> > and who knows what else. So while the error is reported on line 15, it's
> > on line 24 in the sql editor, where I need to fix it. There is no
> > pointer to line 24 that I can find...if I select Edit Go To line 15, it
> > goes to line 15 in the editor, not line 15 in the sql (according to
> > whatever standards it uses to compute a line of SQL).
> >
> > It's a very annoying aspect of SSMS. I want to know on what line in the
> > editor the error is on. There must be a simple workaround for this?
> >
> > Why would Microsoft has the error reported in such a useless manner
> > after so many editions of SSMS? So far I've not found anything on this
> > by googling but maybe...
>
>