SSMS shortcut to comment/uncomment a specific part of the query? I'm looking for an option to comment/uncomment a particular part of the query with the Slash Star Comment option. 

Scenario:

While debugging the queries with N numbers of JOINs, I comment out each table in the join and its related conditions one by one and find which table causing the issue or wrong data. If the commented table didn't cause the issue, I will uncomment the table and its related condition and try with the next table.

For this purpose currently I manually add -- comment in front of the particular line or press Ctrl + C to comment the entire line, if the select/conditions are in middle of the line, I move the select/condition alone to the next line and add -- comment. If there is no issues with the join, again I undo the changes or Ctrl + U to uncomment. 

Moving the condition to the new line and adding the comment is burden to me, some time it caused bad alignment too.

Expectation:

What I want is need some shortcut key to add the /* in front and */ in end of the selected text.

Samples:

The below is the sample case, which my query looks like (in actual it may contain more select columns, tables and conditions).

SELECT T1.Id, T1.Name, T1.Designation, T1.CreatedDate, 
       T2.AccountName, T3.LinkId, T3.LinkName, T4.OwnershipName
FROM TableOne T1
INNER JOIN TableTwo T2 ON T2.Id = T1.Id AND T2.Name = T1.Name
INNER JOIN TableThree T3 ON T3.Id = T2.Id AND T3.IsActive = 1
INNER JOIN TableFour T4 ON T4.Id = T1.Id AND T4.LinkId = T3.LinkId AND T4.IsActive = 1
WHERE T1.CreatedDate BETWEEN @FromDate AND @ToDate AND T1.DeletedDate IS NULL
    AND T2.DeletedDate IS NULL AND T3.DeletedDate IS NULL AND T4.DeletedDate IS NULL 


Here if I want to comment the TableThree and its related content in the SELECT, JOIN and conditions in WHERE. I will select the content and press the shortcut key to add the /*  */ comment separately.

Expected the behavior is:

SELECT T1.Id, T1.Name, T1.Designation, T1.CreatedDate, 
       T2.AccountName/*, T3.LinkId, T3.LinkName*/, T4.OwnershipName
FROM TableOne T1
INNER JOIN TableTwo T2 ON T2.Id = T1.Id AND T2.Name = T1.Name
/*INNER JOIN TableThree T3 ON T3.Id = T2.Id AND T3.IsActive = 1*/
INNER JOIN TableFour T4 ON T4.Id = T1.Id /*AND T4.LinkId = T3.LinkId*/ AND T4.IsActive = 1
WHERE T1.CreatedDate BETWEEN @FromDate AND @ToDate AND T1.DeletedDate IS NULL
    AND T2.DeletedDate IS NULL /*AND T3.DeletedDate IS NULL*/ AND T4.DeletedDate IS NULL
You can easily do this with Code Snippets, something like this will work for your example:

&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
    &lt;_locDefinition xmlns="urn:locstudio"&gt;
        &lt;_locDefault _loc="locNone" /&gt;
        &lt;_locTag _loc="locData"&gt;Title&lt;/_locTag&gt;
        &lt;_locTag _loc="locData"&gt;Description&lt;/_locTag&gt;
        &lt;_locTag _loc="locData"&gt;Author&lt;/_locTag&gt;
        &lt;_locTag _loc="locData"&gt;ToolTip&lt;/_locTag&gt;
        &lt;_locTag _loc="locData"&gt;Default&lt;/_locTag&gt;
    &lt;/_locDefinition&gt;
    &lt;CodeSnippet Format="1.0.0"&gt;
        &lt;Header&gt;
            &lt;Title&gt;SLASH STAR COMMENT (surrounds)&lt;/Title&gt;
            &lt;Shortcut&gt;&lt;/Shortcut&gt;
            &lt;Description&gt;Surround selected text with slash star comment block /**/&lt;/Description&gt;
            &lt;Author&gt;wBob&lt;/Author&gt;
            &lt;SnippetTypes&gt;
                &lt;SnippetType&gt;SurroundsWith&lt;/SnippetType&gt;
            &lt;/SnippetTypes&gt;
        &lt;/Header&gt;
        &lt;Snippet&gt;
            &lt;Declarations&gt;
                &lt;Literal&gt;
                    &lt;!--&lt;ID&gt;x&lt;/ID&gt;&lt;ToolTip&gt;y&lt;/ToolTip&gt;&lt;Default&gt;z&lt;/Default&gt;--&gt;
                &lt;/Literal&gt;
            &lt;/Declarations&gt;
            &lt;Code Language="SQL"&gt;
                &lt;![CDATA[/* $selected$ $end$ */]]&gt;
            &lt;/Code&gt;
        &lt;/Snippet&gt;
    &lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;


Save the file with a .snippet extension and follow the instructions from here to add the snippet to SQL Server Management Studio (SSMS).  

Instructions for use


highlight the text you want to surround with the comment block in the query editor
Press Ctrl+K, Ctrl+S to summon the 'Surround With' snippets.  Note the comma between the two sequences, it means "press Ctrl+K, then press Ctrl+S in quick succession"
Select your snippet from the list
Your highlighted text is surrounded with the comment block
press Ctrl+Z to Undo - this is the normal windows undo command.  It will remove the comment block as long as you haven't made any other edits.