SQL Shortcuts keyboard

5 Game-Changing SQL Server Shortcuts

In this article we’ll show you five little-known SQL Server Management Studio tips and tricks that even veteran SQL coders may not be aware of. By learning these shortcuts you can massively improve your SQL speed and efficiency, and its a fun way to impress your coworkers.

(If you’re new or just want to try these tricks, you can download SSMS for free here)

1.) Instantly preview tables without writing a Query:

This is a trick I learned from a legendary Microsoft DBA years ago and have gotten dozens of colleagues to start using as well.

Simply highlight the table name (double click or drag cursor) and hit CTRL+3:

To set it up: First go to Tools -> Options

Now enter this for the CTRL+3 Query Shortcut:

Now make sure to restart SSMS, and you’re good to go!

Bonus: for CTRL+5 I use ‘Select count(*) from’ to easily see a tables row count. Works great for temp tables especially.

2.) See Table Schema, Data Types, and Indexes without writing any SQL:

This one requires no setup. The only caveat is you must be using the database the table is located in, you cannot go cross-DB. So make sure you select the correct database in the top left ‘database selector’ box (Side note – If you’re curious, this executes the built in stored procedure ‘sp_help’)

Highlight the table name -> hit ALT+F1

Results:

Table Info: Tells you the Name, Schema, type, and even when the table was created.

Columns and Datatypes: Gives every column in the table, and the two keys here are the Data Type and Length. This can be especially helpful when inserting data or determining how to handle an export.

Index Info: This is the best one right here. You can quickly see what columns the indexes are created on. If a query is running slow this is the first place to look to see where the index lies so you can target those columns for filtering/joining.

You can even do this for Temp tables by selecting TempDB in the database selector box. I find this pretty handy for troubleshooting

3.) Quickly comment and uncomment lines:

This one is pretty simple but extremely useful:

Highlight the lines you want to work with:

CTRL+K+C to comment them out

CTRL+K+U to uncomment them

4.) Write on multiple lines at once:

This one is especially useful if working with a long CASE statement or long select lists. It will come in handy far more than you’d think

Hold ALT+SHIFT and use the Arrow keys to go to multiple lines at once

And then type away as such:

5.) CTRL+SHIFT+R To Refresh IntelliSense

This ones seems minor but it gets used more than you’d think

If you’ve been creating or changing tables, sometimes IntelliSense wont recognize the new changes and will flag your new fields as errors and not offer autocomplete for them.

In order to refresh IntelliSense up to the latest changes you can press CTRL+SHIFT+R

I hope you’ve enjoyed these SQL Server tips, stay tuned as there are many more to come