-2

I have used nested comment blocks in the past while writing queries using SSMS and never thought about whether or not it was alright. I was giving Azure Data Studio a try and noted that it doesn't handle nested comments in the same way.

This is why I want to ask: Do DB Developers use nested comment blocks?

If I enter a block of code with nested blocks of comments such as this:

/*
    SELECT 1
    /*
        SELECT 2
    */
    SELECT 3
*/
SELECT 4

The code text coloring in Azure Data Studio (and here) appears incorrect:

Azure Data Studio Code Highlighting

In SSMS the same block of text produces what I would expect:

SSMS Code Highlighting

I appreciate a visual confirmation of what is going to happen when I hit execute. With Azure Data Studio, I definitely hesitate to run any file that contains nested comments because I don't like the potential for unexpected activity.

3
  • The ADS behavior seems like a bug, since the syntax highlighting does not match the query behavior. As to whether people do this, or how often, I can't say. I personally find it confusing for the same reason ADS has trouble parsing it, so I do not like nested comments like that--but opinions are off-topic for the site as answers.... so it doesn't really matter whether I like it or not. 😊
    – AMtwo
    May 12 at 16:30
  • I find it confusing too and I'd rather use a single comment block.
    – McNets
    May 12 at 16:32
  • The only reason I have ever done this is if, while working on a solution, I want to have a quick query block that is easily identifiable while scrolling. Something that might allow me to quickly truncate, drop, or create records as applicable to a test scenario or to view output.
    – Silvanarix
    May 12 at 16:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.