Line number in stored proc

  • Hi All,

    Is there any way to find the line number in the stored proc. Say i have 800 lines of code in a stored proc but i get an error at line number 406. How can I find line# 406?

    Thanks,

    Kayal

  • You should be able to double-click on the error message text and it will take you to the offending line.

  • You can also use Ctrl-G to go to a specific line. Keep in mind that if you have all the usual stuff at the top of a proc, the error line might be below the absolute line.

    For example:

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    create proc XXX

    as

    ...

    Because of the set commands and such at the top, the proc begins at line 5, and so you have to subtract 4 (one less) from the error line, if you use Ctrl-G. Or delete the lines above "create proc". Either one works.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Also, there is a current line counter in the status bar.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • And you can turn on line numbers so that they're displayed by going to "Tools," "Options," "Text Editor," "TSQL" and under the Display choice selecting "Line Numbers."

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 5 posts - 1 through 4 (of 4 total)

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