Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2014: report text of query executed via shortcut in query window

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.

like image 752
frankieta Avatar asked Nov 20 '25 14:11

frankieta


1 Answers

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

like image 104
MJohnson Avatar answered Nov 23 '25 03:11

MJohnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!