Query Analyzer is one of the most frequently used utilities in SQL Server's tool set. As every DBA knows, Query Analyzer is essentially SQL Server's command console. Query Analyzer's GUI makes it easy to use. In fact, you can easily overlook the fact that Query Analyzer doesn't just provide a GUI-style point-and-click interface—it also provides full support for a set of keyboard shortcuts that make Query Analyzer a more effective and productive tool. Taking advantage of these shortcuts lets you quickly enter and execute SQL statements without needing to take your hands off the keyboard to use the mouse. Here are seven keyboard shortcuts that can help you be more productive when you're using Query Analyzer.

7. F5
The F5 key is the keyboard shortcut that I use most frequently. Pressing the F5 key runs the current query and lets you avoid taking your hands off the keyboard to click the green run icon.

6. F8
You can use the F8 key to quickly toggle the display of the Object Browser window in the left side of the Query Analyzer window. If the Object Browser window is displayed, pressing F8 closes it. If the Object Browser is closed, pressing the F8 key displays it.

5. F4
Pressing the F4 key displays Query Analyzer's Object Search dialog box. Object Search lets you search for a table name, view, stored procedure, user-defined function (UDF), column, index trigger, extended stored procedure, or constraint in one database or in all the databases on the server. You can set up more than one search criterion by pressing F4 multiple times.

4. Alt+F1
The Alt+F1 keyboard shortcut is a quick way to run the sp_help stored procedure. If nothing is selected in the Query Analyzer window, Alt+F1 runs sp_help for the current database. If the name of a database object is selected, sp_help runs for the selected database object.

3. Ctrl+1
Another handy keyboard shortcut, Ctrl+1, runs the sp_who stored procedure. If a SQL Server login name is selected in the Query Analyzer window, sp_who runs for the selected database object. If no name is selected, Ctrl+1 runs sp_who for the database you're currently in.

2. Ctrl+2
The Ctrl+2 keyboard shortcut executes the sp_lock stored procedure for the current database. This keyboard shortcut doesn't let you use parameters.

1. Your Own Shortcuts
The best keyboard shortcuts are always your own, and Query Analyzer lets you add as many as nine of them. From the Tools menu, select Customize, then select the Custom tab. You can choose a keyboard combination and enter the name of a stored procedure that you want to run when you press that keyboard combination.

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Query Analyzer Shortcuts in recent magazine online. Im running sql70 and my short cuts in query analyzer dont work.

Phil Dahlin

It would be good to specify which version of SQL Server these shortcuts work with. I tried these with SQL Server 7.0 Query Analyzer, and the only shortcut that works is F5.

Alan Roberts

Dont forget the most important one, Ctrl + E, this one I prefer before F5, why, simple because when working in QA I write a whole lot of SQL strings and by mark the string I want to execute and only that one, when pressing CTRL+E executes only the marked string and leaves the rest, where nice feature.

Another on is the F8, toggles the object explorer in QA, nice...

And the last one is CTRL+R, this one toggle the result window, you know, when you get mad because the result window occupie almost the whole screen, by pressing CTRL+R you quickly remove it.

thanks for a nica article

Goofy

Its for Goofy, You dont have to press 2 keys which u have told Ctrl+E u can just highlight the query and press F5

Anonymous User

Article Rating 3 out of 5

Its for Goofy, You dont have to press 2 keys which u have told Ctrl+E u can just highlight the query and press F5

Anonymous User

Article Rating 3 out of 5

How about creating your own short cuts. I want to make my own for SELECT * FROM "Highlighted Text".

Where you pass the highlighted text into the SP. How can I do this???

Anonymous User

The BEST short cuts are SHIFT CTRL R and SHIFT CTRL C for Remove comment and Comment respectivly

Anonymous User

Article Rating 4 out of 5

If you want to make your own for SELECT * FROM "Highlighted Text", create a stored proc with parameter @tablename and the line "EXEC('select * from ' + @tablename)". Then just put the name of the stored proc in the shortcut.

Anonymous User

Article Rating 3 out of 5

PromptSQL adds SQL intellisense to query analyzer, giving name completion when press '.' after a name, or when you press Control-Space.

It even does stuff like suggesting join conditions if you press Ctrl-Space after ON.

http://www.promptsql.com/

Anonymous User

Article Rating 5 out of 5