comment block
I would like a feature to place a hilited block of code into a comment block /**/ - rather than having inline comments (helps when capturing the running sql in monitoring tools)

The latest version of SQL Prompt has the $SELECTEDTEXT$ placeholder which allows you to use the current text selection in your snippets. So to surround a selection with a comment block you could create a snippet similar to: /* $SELECTEDTEXT$ */
-
Eric Isaacs commented
In SSMS if you want to comment out a block of SQL, there are existing buttons which already append -- or remove -- from the beginning of each line. The Red-Gate Comment and Uncomment does exactly the same thing, making it not very helpful. I never use the Red-Gate SQL Prompt comment/uncomment because it's too many steps whereas the SSMS Control+k+Control+c comments a block with -- comments and control+k+Control+u removes those comments. SQL Prompt's comment feature adds nothing that isn't already there in SSMS.
However, having the ability to select a block of text and use the "list of actions" in SQL prompt to append the /* and */ comment blocks would be a feature that would actually be worthwhile to use. It would be awesome if you could customize that comment block though, as I actually prefer:
/*
the text
that
was selected
here
--*/...as an even better comment block because the /* at the beginning can be commented out with --/* making the comment block go away in SQL.
I'd love to talk to a SQL Prompt product manager about this if it's unclear what the issue is with the existing comment functionality and what this original requester was requesting.
In short, there are 2 ways in SQL to do comments:
-- comments out one line
/*
comments
out
a
block
of
text
*/SSMS already has built in buttons and shortcuts to add -- comments to all selected lines and to remove them too.
SQL Prompt's existing comment/uncomment functionality does exactly what SSMS does already.
No tool adds the /* and */ around selected text though. And the /* commented text --*/ is a SQL trick that only the more seasoned SQL Developers know. I'd personally prefer the /* --*/ comment blocks, but most people would be happy with the /* */ comment blocks.
https://celedonpartners.com/line-comment-block-trick-sql-server-t-sql/
-
Eric Isaacs commented
This solution is unclear. If you have text selected, how do you use a snippet? Snippets are typed and you hit TAB to insert the snippet text. The snippet can select text within the snippet, but as far as I know, you can't select text and then use a separate snippet. I too want what this requester is requesting, but I don't think the proposed solution is a solution. I'd love to be wrong, though. It just doesn't make sense.
-
DataDog commented
He is talking about "Comment selection" the SSMS built-in always uses inline comments (--) as opposed to block comments (/**/)
-
I'm not sure I understand what you mean. Would you be able to elaborate?