Quick-type Macro

John Hunter 1 Reputation point
2022-01-13T03:56:22.943+00:00

Is there some way to quickly type common SQL, like "select * from x where y order by z"?
I often need to type this multiple times a day into a query editor window. A keyboard shortcut would save a lot of time (cumulatively)
I don't want to open a file with a template; the number of clicks and key presses is as much as typing the code, and it distracts from my train of thought
I can't use a Query Shortcut as that executes code; it doesn't type it on screen

SQL Server | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,441 Reputation points
    2022-01-13T06:32:44.59+00:00

    You can create & use templates in SSMS for such requirement, see

    Template Explorer
    Use templates in SQL Server Management Studio

    0 comments No comments

  2. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-01-13T07:10:18.587+00:00

    Hi @John Hunter ,

    You can follow below steps to create T-SQL query shortcut in SSMS. SSMS -> Tool-> Options;

    164662-screenshot-2022-01-13-150843.jpg

    Please refer to this blog Creating T-SQL Query Shortcuts in SQL Server Management Studio(SSMS) to get detail steps.

    >I can't use a Query Shortcut as that executes code; it doesn't type it on screen

    Sorry for missing this sentence. If that, copy these T-SQL in one text, then CTRL+C and CTRL +V also very quickly.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.