Tara Kizer Blog

Tara Kizer

Commenting Blocks of Code in SQL Server 2005

In Query Analyzer, we could easily comment blocks of code using Ctrl+Shift+C and uncomment blocks of code using Ctrl+Shift+R.

These keyboard shortcuts do not work in Management Studio unless you switch the keyboard scheme to SQL Server 2000.

In Management Studio, you can comment blocks of code using Ctrl+K, Ctrl+C and uncomment blocks of code using Ctrl+K, Ctrl+U.  These are the same keyboard shortcuts that you would use to comment blocks of code in Visual Studio .NET, so I'm sure that's why Microsoft decided to switch the shortcuts. 

To see other keyboard shortcuts for T-SQL code in Management Studio, open a query window by clicking the New Query button.  Click on the Edit menu then Advanced.  You must be in a query window for the Advanced item to appear in the Edit menu. 

Legacy Comments


leigh
2006-09-14
re: Commenting Blocks of Code in SQL Server 2005
Hey Tara
when i try and comment code using ctrl+c in management studio it doesn't work, wierd. so i changed the option under tools, options, environment, keyboard, there changed the keyboard scheme to SQL 2000. now i have the old favourite shift+ctrl+c for comments and shift+ctrl+r for uncomment.

Jon
2006-09-14
re: Commenting Blocks of Code in SQL Server 2005
You can still use the 2k way by changing the default keyboard schema in MS

Jon
2006-09-14
re: Commenting Blocks of Code in SQL Server 2005
Opps first poster already said that..should of read :).

Tara
2006-09-14
re: Commenting Blocks of Code in SQL Server 2005
Leigh,

You have to hit Ctrl+K, Ctrl+C. It requires both. Ctrl+C is of course copy.

Yes I am aware that you can change it to the 2000 keyboard. But I hate to stay back in the times, so I've adopted the new keyboard layout.

Leigh
2006-09-14
re: Commenting Blocks of Code in SQL Server 2005
aah that's better, thanks Tara

David
2006-11-08
re: Commenting Blocks of Code in SQL Server 2005
What's wrong with /* ... */ ? Is it just a coding speed thing?

-D.