r/SQLServer • u/unidotcon • Oct 14 '26
Discussion Brainstorms on SQL query custom shortcuts in SSMS
What are the most frequently used T-SQL queries to have and what are the best keys to use.
So far I have been using "SELECT * FROM" and "SELECT TOP 1000 * FROM" a custom line called "sp_ts". I wanted to see if you guys have other queries that would save loads of time.

3
Upvotes
4
u/SQLBek 1 Oct 14 '26
Here's my favorite...
https://sqlbek.wordpress.com/2015/07/14/t-sql-tuesday-68-changing-ssms-shortcut-defaults/
3
u/Furnie Oct 14 '26
I have a few.
Ctrl+6: Select top 100 * from <Log database>.dbo.v_progresslog order by 1 desc
This shows me what's recently run.
Ctrl+7 If DB_NAME() = 'DBName1' use DBName2 Else If DB_NAME() = 'DBName2 ' use DBName3 Else If DB_Name() = 'DBName3' use DBName4 Else IF DB_Name() = 'DBName5 ' use DBName1 Else Use DBName1
This allows me to quickly change my active database by looping through the commonly used databases. Unfortunately I can only run it on one specific instance as If the database names don't exist the query fails to run, even if the logic wouldn't call that bit.
Ctrl+8: it's a bit long to go through psudomonising, but it checks the @@ServerName value and depending on what it returns, does a select that unions a sumary of our data freshness tables for that instance, so at a glance I can see when the most important tables for the instance were last updated.
1
u/chenqiao Oct 17 '26
For query shortcuts, I rely heavily on metadata queries. Here are my favorites:
Ctrl+3 -> sp_helptext: Select a proc or view name, hit Ctrl+3, and instantly see the definition.
Ctrl+4 -> sp_help: Select a table name, hit Ctrl+4, and see all columns, data types, and indexes.
Alt+F1: (Default) sp_help. Still undefeated.
Instead of mapping a shortcut to SELECT * FROM, mapping to SELECT TOP (100) * FROM is usually safer for production environments. Also, a huge timesaver is mapping a shortcut to SELECT * FROM sys.dm_db_index_usage_stats when troubleshooting.
3
u/Decent_Golf_3960 Oct 14 '26
I use ctrl+0 to run sp_whoisactive. Comes in quite handy.
1
u/navicat-gu 26d ago
Good list in the comments already. A few more that save me time, grouped by what they're for. In SSMS they go under Tools > Options > Environment > Keyboard > Query Shortcuts, and the shortcut runs with the selected text appended:
sp_help(columns, keys),sp_helptext(definition of a view or proc),sp_helpindex.sp_findthat searchessys.objectsandsys.sql_modulesfor a name or string. Select a word, hit the key, and you see every proc that references it.sp_WhoIsActive(Adam Machanic) with your favourite parameters, andsp_BlitzWhofrom the First Responder Kit.sys.dm_db_partition_statsgrouped by table, much faster thanCOUNT(*)on big tables.Two tips: keep the procs in a shared utility database (or
masterwith thesp_prefix so they resolve from any database context), and keep the list in source control so it survives a new laptop. For longer templates, SSMS code snippets (Ctrl+K, Ctrl+X) are better than shortcuts.Disclosure: I'm RC, Director of Digital Strategy @ Navicat. If you also work outside SSMS, Navicat 18 has reusable code snippets for SQL Server that can sync across machines, and that's included in the free Navicat Premium Lite.