4/25/2011 8:54:29 AM
Amit Karkhanis -
Reading Amit Bansal’s tips on SQL Server Management Studio, I also remembered the old days when we used to do such small tweaking to automate some of the tasks in SSMS. I would also like to share here one tip which enables us to maintain shortcuts for certain commands which we use most of the time and hence saves a little typing time.
There is a provision to define certain shortcut keys in SSMS. Press Alt+F1 in an empty query window and you will get the entire object list inside a database (sp_help). Pressing Ctrl+1 executes sp_who command which Provides information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. So can we customize this to add our own shortcuts to execute commands which we use most of the time? Let’s see how...
In SSMS, Click on the Tools menu and select Options.
In the options window, expand Environment and select Keyboard. Here you can configure the query shortcuts and assign them to particular keys. Observe that Alt+F1, Ctrl+1 AND Ctrl+2 are assigned by default to sp_help, sp_who and sp_lock respectively and can not be changed. We can use the other keys to customize our own shortcuts. In this example, I have set the following,
Ctrl+F1 - select * from sys.tables order by name
Ctrl+3 - select getdate()
This setting will take effect only for the new query window and not the query windows already opened. Open a new query window in AdventureWorks database and press Ctrl+F1. You will get the list of all the tables in this database. Press Ctrl+3 and you can see the system date and time.
Amit Karkhanis (Member since: 3/14/2011 10:05:08 AM)
View Amit Karkhanis 's profile
Amit, nice info :)
Nice tip, Thanks
Leave a comment