Use Ctrl+F1 as a “preview” button in SSMS

Every time I set up SQL Server Management Studio, I take the time to add a shortcut to the “Query Shortcuts” section of the options:

Tools -> Options -> Environment -> Keyboard -> Query Shortcuts

On the surface, these query shortcuts are just what the name implies – a key combination that you can press to run a command or execute a stored procedure. But there’s a hidden super power: whatever text you’ve selected in SSMS when you press the keyboard combination gets appended to the shortcut statement.

So if you select the name of a table, for instance “dbo.Votes”, and press Ctrl+F1, SSMS will run:

SELECT TOP (1000) * FROM dbo.Votes
Preview the contents of a table

This allows you to create a keyboard shortcut to instantly preview the contents of a table or view.

And you can select not just the name of one table, but any other query text you want to tack on:

Preview the contents of two joined tables.

Because we’ve selected both the name of a table and the next line, pressing Ctrl+F1 in SSMS will effectively run the following command:

SELECT TOP (1000) * FROM dbo.Votes AS v
INNER JOIN dbo.VoteTypes AS vt ON v.VoteTypeId=vt.Id

You can go on to include as many joins, WHERE clauses, ORDER BY, as long as the syntax makes sense:

Remember that query shortcuts only apply to new windows, so if you change them, you’ll have to open a new window for the change to take effect.

13 thoughts on “Use Ctrl+F1 as a “preview” button in SSMS

  1. Pingback: Binding a “Preview” Shortcut in SSMS – Curated SQL

  2. “Let me hear your thoughts!”
    I have no thoughts because my brain just got shattered :o

    I never knew about this… This gives a tonn of possibilities :)

  3. This is class. I will do another one for select count(*) from –
    When I am trying to find which join is duplicating/dropping rows in a huge query this will be so good.

    I will also do one for drop table. Sometimes when you have temp tables created by a SELECT INTO and you want to rerun the statement but have to manually drop the table… bit risky but worth a go

  4. It’s been a while since I found out about this. And for some reason I shy away from interfering with F-Keys, so my shortcuts look like this:
    Ctrl-3: SELECT COUNT(*) FROM
    Ctrl-4: SELECT TOP 10 * FROM

  5. Here’s how I’ve configured my shortcuts. It might be worth mentioning that some updates to SSMS have cleared out them out, so I keep a local save just in case.
    –ctrl+4 SET STATISTICS IO, TIME ON
    –ctrl+5 SELECT COUNT(*), FORMAT(COUNT(*), ‘#,#’) FROM
    –ctrl+6 SELECT [Count] = COUNT(*), [CountF] = FORMAT(COUNT(*), ‘#,#’), [Checksum] = CHECKSUM_AGG(CHECKSUM(*)) FROM

  6. Doesn’t work for me. Using SSMS 18.11.1. The output I get is:

    Commands completed successfully.
    Completion time: 2022-05-03T11:53:09.7848407-04:00

    To be fair, I’m editing for Ctrl+F5 instead of Ctrl+F1, but I can’t see that should make a difference.

    Any ideas?

Let me hear your thoughts!

This site uses Akismet to reduce spam. Learn how your comment data is processed.