Sunday, September 06, 2015

Awesome SSMS shortcuts that will save you tons of time

How many times have you written a join with a bunch of tables and you wanted to quickly see what was in a table. You would either find the table in object explorer, right click and click on SELECT top 1000 rows

This would produce something like the following
/****** Script for SelectTopNRows command from SSMS  ******/
SELECT TOP 1000 [lastrun]
      ,[cpu_busy]
      ,[io_busy]
      ,[idle]
      ,[pack_received]
      ,[pack_sent]
      ,[connections]
      ,[pack_errors]
      ,[total_read]
      ,[total_write]
      ,[total_errors]
  FROM [master].[dbo].[spt_monitor]
What if I told you that there is a way, way better and faster way.....
In SSMS click on Tools then Options, from the right site pick Environment-->Keyboard-->Query Shortcuts you should see something like the following


In the CTRL + 5 shortcut space enter the following select top 100 * from 
Make sure you have a trailing space after from
Hit OK, now restart SSMS because it won't take effect right away
Once you have restarted SSMS and have connected to a database, in a new query window type any table name that you want, for example if you are in the master database type spt_values, double click on the table name so that it is highlighted, now press CTRL + 5 and voila you should see 100 rows from this table....

Now you can just click on any table or view and see the 100 rows, this way you can easy see what the table looks like

You can also do this with sp_helptext, here is how you do it, add sp_helptext where CTRL + 6 is, make sure you have a trailing space after the proc name

Restart SSMS again, type a proc name, double click on the name, hit CTRL + 6 and you should see the definition in the output

There you have it..some time saver shortcuts. You can also do this with other queries and procs...what are some of your favorite shortcuts?

No comments: