question

Darth_pathos avatar image
Darth_pathos asked

Trying to set up shortcuts for text to be inserted in code editor

I'm using SQL Server 2008 R2 on Windows 7. I'm trying to set up Shortcuts so that I can have joins between tables, comments I want inserted etc. to be standardised. I've found the article http://social.technet.microsoft.com/wiki/contents/articles/3178.how-to-create-query-shortcuts-in-sql-server-management-studio.aspx and have been given help by Jes Borland on Twitter, but no such luck. When I restart SSMS and press the shortcut combination (CTRL-4, for example), I get a "Command Completed Successfully" in the Messages tab but nothing inserted in my editor. The default shortcuts, which point to stored procedures work fine, and when I assign sp_HELP to CTRL-4, it also works. This was supposed to be a quick thing I did between coding two different projects but has now taken 45 minutes.... Any help would be appreciated. Thanks Chris
ssmsshortcut-key
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
That's because those commands execute queries. They don't insert text. Having a piece of T-SQL code that is not a full execution of a query won't work. It'll generate an error based on whatever syntax issue you have. But, you can use the [Code Snippets][1] to insert text. It's not great frankly, but it does work. If you really want to see this done right, you should look at [Red Gate SQL Prompt][2]. [1]: http://technet.microsoft.com/en-us/library/gg492130.aspx [2]: http://www.red-gate.com/products/sql-development/sql-prompt/
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.