Thursday, June 01, 2006

SQL Management Studio Short Cuts

I have been working with SQL Management Studio (SMS) a fair bit lately. Like most developers I always look for the standard short cuts that I used on Query Analyser. Below are a few of my favourites.

Commenting

I use these short cuts all the time to comment large sections of code. The comment style I prefer the most is dash form which I prefer too the slash style. -- Dash Comment /* Slash Comment */


  • To comment in SQL management studio you must now do Ctrl+K, Ctrl+C instead of Ctrl+Shift+C in Query Analyzer.
  • To uncomment in SQL management studio you must now do Ctrl+K, Ctrl+U instead of Ctrl+Shift+R in Query Analyzer.

Formatting

  • To indent a block of code Select the code you would like to indent and press TAB to indent
  • Shift+TAB to un-indent your code
  • Word Warp long strings with Ctrl+E, Ctrl+W
  • Make Uppercase Ctrl+Shift+U
  • Make Lowercase Ctrl+Shift+L

Bookmarks

Ok so you are working on a massive script that travels for miles. Well then you better be using book marks to navigate that code. Bookmarks are great for moving through scripts and trouble shooting. Try out the following the next time you are working on a big script.


  • Toggle Book Mark on/off and Crtl+K, Ctrl+K
  • Enable all book marks Crtl+K, Ctrl+A
  • Move to next bookmark Ctrl+K, Ctrl+N
  • Move to previous bookmark Crtl+K, Ctrl+P
  • Move to next bookmark folder Ctrl+Shift+K, Ctrl+Shift+N
  • Move to previous bookmark folder Ctrl+Shift+K, Ctrl+Shift+P
  • Clear book marks Ctrl+K, Ctrl+L

5 comments:

Anonymous said...

I just wanted to comment on some of the info you posted as follows:

To uncomment in SQL management studio you must now do Ctrl+K, Ctrl+U instead of Ctrl+Shift+U


I believe that the old way to uncomment in SQL Query analyzer was Ctrl+Shift+R. Ctrl+Shift+U in Query Analyzer used to make the highlighted text UPPERCASE.

Hope that helps. I'm glad you posted the shortcuts. I always like an easy reference to save me some time. Thanks. --JJDemps

Myles Matheson said...

Thanks JJ,

I reread my post and noticed that I had given the wrong short cuts. I have updated the post to reflect the correct short cuts.

Thanks,

Myles

Myles Matheson said...

Hello Sammy,

At first I found the new short cuts a real pain but after using it day in day out, I got over it.

Anonymous said...

Hi
When you use TAB to indent code it all work fine. You save the code i.e. script or as a SP. When you open it later the whole tab thing go haywire. Any idea to get it to stay in the format in with you saves it.
Jan

Myles Matheson said...

Hello Jan,

I have not had this problem in SQL Management Studio. Are you running SP1 and the roll up hot fix?