39

When there's an error in a SEDE query, you just get the error message.

Incorrect syntax near '*'.

This can leave me guessing as to which one of the * in my query is causing the error.

SSMS seems to be able to give me a line number, so I guess SQL Server is able to provide this info.

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '5'.

Can this be added?

8
  • 7
    workaround: use less * in your queries :)
    – gnat
    Sep 19, 2014 at 15:39
  • @gnat obviously the * is an example. In this particular query I could replace all * instances with a specific field (I'm doing a count()), but I would be none the wiser.
    – Stijn
    Sep 19, 2014 at 15:41
  • 1
    @gnat It be an ugly hack instead. An easier way would be to comment out code line by line until you figure out what the syntax error is and how to fix it, but by then it's counter-productive and the message could be more informative to begin with.
    – Unihedron
    Sep 19, 2014 at 15:41
  • 2
    @Unihedron no, a really general workaround would be to avoid repeating occurrences of anything in SQL altogether, to guarantee that whatever is printed next to Incorrect syntax uniquely identifies the troublesome line
    – gnat
    Sep 19, 2014 at 15:44
  • 1
    @gnat heh, I was wrong, doing the replacing did help me out. Anyway, it would still be a nice feature to have :)
    – Stijn
    Sep 19, 2014 at 15:45
  • 2
    I actually had added this at one point but it got removed due to some other changes I made rendering it less effective. I'll look at re-adding it after I finish up changes to the authentication.
    – Tim Stone
    Sep 19, 2014 at 16:00
  • @TimStone if you are by chance working with something like HandleSuccess, phrase "after I finish up changes" sounds somewhat... scary
    – gnat
    Sep 19, 2014 at 17:50
  • @gnat Nothing quite that terrifying from what I can tell, just improving the SEDE login options. :P
    – Tim Stone
    Sep 19, 2014 at 17:51

2 Answers 2

11

I fully agree with this feature request, but meanwhile, I found a workaround: use the developer tools of your browser to inspect the XHRs. The JSON response from the server does contain the line number:

screenshot of browser with developer tools

5

I've created this pull request that adds the linenumber in front of the error message when the linenumber is present in the response payload.

Do note that the linenumber is as "accurate" as it would be if you run the sql script in SQL Server Management Studio. That accuracy won't get improved/fixed.

Pull Requests have been been reviewed and approved by SE devs. This is now deployed and live in rev 2020.12.13.80.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .