4

Does anyone know if there is an add-in or if there is a place where you can save frequently used SQL queries, besides keyboard shortcuts? I would want to save a query like this one to a "Favorites" location so I can reference it when I need it. I would want to change the 'Where' criteria for c.name LIKE '%%'. Which is why keyboard shortcuts wouldn't work.

PS: I don't have SA or admin rights on my DB.

SELECT 
t.name AS table_name, 
SCHEMA_NAME(schema_id) AS schema_name, 
c.name AS column_name 
FROM 
sys.tables AS t 
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID 
WHERE 
c.name LIKE '%%' 
ORDER BY schema_name, table_name;
1
  • ssms allows you to save queries to your local file system. It's on the main menu under File.
    – Dan Bracuk
    Sep 18, 2013 at 19:40

2 Answers 2

6

You can use the Template Explorer (keyboard Shortcut is Ctrl + Alt+ T) In Template explorer right-click to create new Template and Edit it to type in your query. For each query, you can select it by double-clicking on it.

1

Correct: You need template explorer, as written above. Addition: You can add your own templates using following path schema:

C:\Users\WIN_USERNAME\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\Templates\Sql\GROUP\TEMPLATE NAME.sql

If you have some very-frequently used scripts and want to have them on fingertips you might find this feature useful: http://www.ssmsboost.com/Features/ssms-add-in-autoreplacements SSMSBoost auto-replacements

"Autoreplacements" allow to define some snippet, that will be inserted after you type token and press space/enter/tab. This is frature of SSMSBoost add-in for SSMS, which I develop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.