question

JohnHunter-3083 avatar image
0 Votes"
JohnHunter-3083 asked Cathyji-msft edited

Quick-type Macro

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-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered

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

Template Explorer
Use templates in SQL Server Management Studio


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered Cathyji-msft edited

Hi @JohnHunter-3083,

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".



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.