Is there a way to bind SSMS 2012 keyboard shortcuts to a procedure in a way where I can pass the fully qualified object name?

南楼画角 提交于 2019-12-10 19:59:35

问题


In SSMS 2012, is there any way I can bind a keyboard shortcut (e.g. Ctrl-5) so that I can highlight a qualified object name (e.g. master.sys.objects) and invoke my own procedure using that object name as the argument?

I know that this does work if I explicitly add quotes or brackets around the object name prior to using the keyboard shortcut (e.g. highlight the string 'sys.objects', but this becomes tedious when wanting to use my shortcut easily by directly highlighting tables in existing queries.

For more context, I noticed that Alt-F1 (the shortcut for sp_help) now supports fully-qualified object names. For example, highlighting sys.objects and pressing Alt-F1 works perfectly in SSMS 2012 (it does not in SSMS 2008). Here is the relevant Connect issue that describes this enhancement.

However, when looking at the keyboard binding for this shortcut, it looks like this action should be synonymous with invoking sp_help on the highlighted text:

This turns out not to be the case, as you can see by running the following two calls to sp_help, both of which fail with error Incorrect syntax near '.'.:

USE master
GO
EXEC sp_help sys.objects
GO
EXEC sp_help master.sys.objects
GO

If there is a way for me to be able to invoke my own procedures similar to the way sp_help can be invoked on qualified objects without brackets or quotes, I would love to know!


回答1:


SSMS 2012 supports 2 part names without quotes, for 3 part names you still need the quotes.

I still have not found any plugin that supports what you want, perhaps you could make a macro on SSMS Boost(http://www.ssmsboost.com/) to automatically add brackets, run your command then remove the brackets. I have not tried to do anything like this with it but it should be possible



来源:https://stackoverflow.com/questions/11974652/is-there-a-way-to-bind-ssms-2012-keyboard-shortcuts-to-a-procedure-in-a-way-wher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!