To Open Microsoft SQL Server Management Studio:
Press windows key+R, type ssms and click Ok (or hit Enter).

TO Create a new query:
Press Ctrl+N.

Open Existing query:
Press Ctrl+O.

Change the database:
When you are in a query windows Press Ctrl+U first, then either use UP and DOWN arrow Keys to change the database OR type a first character of your database to jump to the database and hit Enter. (Note: If u have several database starting with same first character, repeat that first character until it appears and hit Enter).

For parse:
Select the code to be parsed and press Ctrl+F5.

For Execute:
Select the code to be executed then press F5.

Result Pane:
After executing or parsing, the result pane is shown, to turn it off or on press Ctrl+R.

To show result in a text format:
By default when we execute the query, ssms display the result in a grid format. But if we want to change this grid format to text format press Ctrl+T just before executing your query. Once you pressed a Ctrl+T then you do not have to repress the Ctrl+T.

To send your result to a file:
If you want your result to be saved in a file (file will be saved in a rpt extension by default) press Ctrl+Shift+T. Then whenever you execute queries SSMS display the windows to give the name for a file. Just give the name and save it. But if you want to save your result in a text file format then in the File name field: Give your desired filename and just give the extension .txt and next thing to do is under the Save as type field: dropdown the list and choose all files. Now just save it. You will get the text file format. E.g-
File name : Example.txt
Save as type: All files (*.*)

To undo the result displaying in a different way back to the grid format or default:
If you want your result back to the default grid format press Ctrl+D and execute any queries at any time.

For execution plan:
Ctrl+L

For always execution plan while executing queries:
Ctrl+M (Note: To undo this setting just repress Ctrl+M).

For client statistics:
Shift+Alt+S (Note: To undo this setting repress Shift+Alt+S).

Template explorer:
Ctrl+Alt+T

Commenting:
To write a comment use double hyphen --
E.g: --This query

Commenting out single line code:
When writing code if you want that code to be commented then press just once Ctrl+K+C.

Commenting out Number of lines Code:
When you need to comment out lines of code (or number of lines) then First select the specific lines then press just once Ctrl+K+C.

Removing the Comment (or Uncomment) made by above method:
If you have made a comment by only the above method, then this method is useful to remove the comment. To remove comment (or uncomment) press Ctrl+K+U.

Commenting out single or multiple line code using multiple line comment just as in c, cpp, java etc.
Use this: /**/
E.g1:  /*Hello I am single line code*/
E.g2:

/*Hello 
I 
am 
multiple 
line code*/
   
But try to avoid this method in sql server management studio..

Indenting Code:
As indenting the code is best practice so to increase the indent select specific code(or lines of code) and hit tab.
To decrease the indent select specific code(or lines of code) and press Shift+Tab.

Bookmarking the code:
To make you easy to navigate number of lines of code, bookmarking is possible in microsoft sql server management studio.
To Bookmark the code press Ctrl+K+K.
To clear all Bookmark form current windows press Ctrl+K+L.
To move to the next bookmarked line from from current cursor location press Ctrl+K+N.
To move back to the last bookmarked line press Ctrl+K+P.

Bookmarks Window:
There might be several bookmarks you have added in your window and if you want to look your created bookmarks in a separate window then press Ctrl+K+W.

To search and find:
press Ctrl+F and give your keyword to be search in Find what field, then press Enter continuously (or F3) to find next keyword match.

To find and replace:
Press Ctrl+H.
Give your keyword to be find in Find what field, then give the keyword to be replace by in Replace with field.
If you want to replace all then click Replace all button.
If you want to replace the searched keyword with replace keyword one by one then click Replace button.

Go to the line:
To go to the line press Ctrl+G and give the line number you want to go.

For autocomplete features:
To reduce typing effort SSMS enable the autocomplete features. When you are writing the query it automatically generates your previously inserted value or keyword. But if you want to generate the list there is the shorcut for you, i.e. Ctrl+J or you can use Alt+Right arrow key also the next key is Ctrl+Space.

For stored procedures and functions:
Ctrl+Shift+Space

Other simple shortcuts as usual works in other text editor too:
Ctrl+C to copy the selected text.
Ctrl+A to select all content.
Ctrl+V to paste text.
Ctrl+X to cut selected text.
Del to delete text.
Ctrl+P to print.
Ctrl+Home button to go the beginning of query windows.
Ctrl+End button to go to the end of the query windows.
Ctrl+Shift+Home to select all text from the current location to the beginning.
Ctrl+Shift+End button to select all text from current location to the end.

Post a Comment