I was searching for a way to automatically execute some common queries that I use using a keyboard shortcut in SQL Server 2014.
I found that this is possible to accomplish setting a keyboard shortcut in Menu -> Tools -> Options -> Keyboard (there are already 3 stored procedures saved, sp_who, sp_lock, sp_help), so my main issue is resolved.
For example I can set CTRL + 3 to execute
SELECT ID FROM MY_TABLE
What I miss though is that in this way the executed query text (SELECT ID FROM MY_TABLE) doesn't show in the query window.
Maybe this is trivial but sometimes I need to use that query as a starting point to write other queries, so it would be useful to have the query text.
What about using snippets instead: https://msdn.microsoft.com/en-us/library/gg492130(v=sql.120).aspx
"A Transact-SQL code snippet is a template you can use as a starting point when writing new Transact-SQL statements in the Database Engine Query Editor."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With