Line numbers in Query Analyzer

  • How do I turn on code line numbers in Query Analyzer for SQL2000?

  • To find out the line in QA for a given statement do this:

    1) Place you cursor on a statement in QA for which you want the line number

    2) Then look in the lower right hand corner of the QA screen and you will see the Caret Position for your cursor (line number and column position).

    Now if you just move your cursor up and down the line number will change.

    This is the way I find the line number, although there maybe more than one way to get the line numer.

    -------------------------

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • I know about that. I want the line numbers to be displayed next to the code though.

    If I were designing a code editor, this would be VERY high on the list of features.

    Thanks anyway 🙂

  • I'm afraid this is going backwards - you just don't need line numbers any more. Gone are the days of GOTO and GOSUB...

    Regards

    Simon

  • I think your missing my point.

    If I have 1000 lines of code and I get an error for line 32 or whatever...I want to be able to visually see the line codes. I don't want to have to use ctrl + g or look in the bottom right hand corner. It so much easier the other way.

  • Guess having line numbers would be nice, but at least there is a way to get line numbers.

    Also remember. If you have a script in QA and it contains GO, then the line displayed in errors for any batch but the first, is not the same as the line number displayed at the bottom right hand corner.......

    -------------------------

    Greg Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • I think the address is sqlwish@microsoft.com for suggestions for improvement. This sounds like a good one. It's one of the features I love about TextPad.

    K. Brian Kelley

    http://www.truthsolutions.com/

    Author: Start to Finish Guide to SQL Server Performance Monitoring

    http://www.netimpress.com/shop/product.asp?ProductID=NI-SQL1

    K. Brian Kelley
    @kbriankelley

  • Sent to MS

  • There's two reasons why line numbers won't do you any good. One is as Greg stated: if you have batches (GO) in your code, the line number given in an error is the line number within that batch, not the whole script. Second, the "line number" given in an error is actually the statement number, not the physical line number. You can spread a statement like Select across several physical lines (for readability), but SQL Server/QA still considers it all to be one "line".

    Now, for debugging errors in QA, you can double-click on an error and QA will take you to the offending line, and this even works across batches. But you have to keep in mind point #2 above, because QA will take you to the start of the statement, but the actual error may be several "lines" below if it's a multi-line statement.

    Jay


    Jay Madren

  • I completely agree with Jay, but I too, like line numbers.

    I usually edit stuff in EditPlus and like the line numbers. I wish QA would give them to me, even if they are useless.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • Hey I like that double click on the error message trick to identify where the sql code starts to go south.....

    -------------------------

    Greg Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Here's MS's response...

    Hi,

    Thanks for your response. We will consider adding this for the next release, I am pretty certain it is already there. For now a couple of notes that might benefit you.

    You can double click on the error message and SQL Query Analyzer will “try” to put the cursor on the right line. I say try because the error message that you get from SQL Server contains a relative line number from the batch you are executing. We keep track on which batch is executing so we can correlate this back. However, when executing an SP you can get error in line 10 when your batch looks like:

    exec mydb.dbo.mysp @p1, @p2

    This means that the error as in line 10 of the stored procedure, which we do not have load in the editor, so we highlight the exec mydb.dbo.mysp… statement instead because it is the closest statement possible.

    Again I hope this helps and thanks for the feedback.

    -GertD

    Architect Transaction Services

    (and creator of SQL Query Analyzer)

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply