问题
Terribly worded question above (trying to be short). Lets try that again:
In Microsoft SQL Server Management Studio, when you are editing an SP and execute the sp in the same window, errors show up at the bottom of the screen you can double click to highlight the code causing the error. However, this never lines up, usually being anywhere between 6 to 13 lines from the actual error, usually lower. It will highlight things like comments, etc.
Anyone know how to get these to line up? What constitutes a line in T-SQL?
I have tried all the normal things like putting comments in-line (no effect), removing comments before the alter procedure line (no effect), removing all code before the alter procedure line like SET ANSI_NULLS ON, etc (no effect). Odd.
回答1:
Line 1 for errors = the first line is sys.sql_modules which may be "ALTER PROCEDURE" but could be a blank line. it's different for batches, but the question is about stored procs.
Line 1 for VS and SSMS = 1st line in the window
So, the SET stuff above + any blank lines cause the difference.
Solution: remove everything above "ALTER PROC" so this is line 1.
来源:https://stackoverflow.com/questions/1160296/in-ssms-when-editing-a-stored-proc-how-to-get-the-line-and-error-numbers-to-ma