Management Studio Tips and Tricks – Comments

Some things you take for granted in management studio, they are just there I have used them for years then you find something that someone else uses and you didn’t.  So some of the following might be known some hopefully might  be useful.

 

Commenting out code can be achieved several ways, there is the usual — or you can comment out entire blocks with /* Comments here */

Also as shown below there are buttons for commenting out / uncommenting select text.

 

Comments

 

You can even comment out between lines of code like below. Where OrderDate is commented out within the line

SELECT

     Productname,/* OrderDate, */ Qty

FROM

Orders

 

! Quick Tip, add comments to your code describing what it does it and why if it’s not straight forward as when you come back in 6 months or someone looks at the code it might hlep

 

Management Studio Settings (All versions)

Click on Tools / Options/ Query results / Results to grid .Two settings I religiously change from default.

Options

The include query in result set , shows you the exact query that’s been ran in the comments section as shown below. Once changing these setting they only take effect in a new window. Very useful if you’re running a set of queries and come back to your desk, which one was I up to ? now you know!

Results

Advertisements
This entry was posted in Configuration, Tips & Tricks and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s