Why don't Query Analyzer shortcut keys work?
Updated: 6/20/2008 12:25:00 AM
Requests: 7259

Hopefully we'll see more of the QA shortcut key combinations restored by RTM. For now, there is a toggle to switch keyboard scheme to SQL Server 2000, under Tools/Options/Environment/Keyboard:

And setting this option, then restarting Management Studio, has re-enabled some of the shortcuts we use:

  • Ctrl+K - toggles the "execution plan" setting for results
  • Ctrl+Shift+C - comment
  • Ctrl+Shift+R - remove comments
  • Ctrl+F1 - runs sp_help for the highlighted object name (the environment says it is Alt+F1)
  • Ctrl+R - toggles the visibility of the results/messages panes
  • Ctrl+1 - runs sp_who
  • Ctrl+2 - runs sp_lock

(On my current installation, these all work by default, but I replaced a previous build with the most current, so I'm not sure if this is an artifact of my previous setting, or they have changed these combinations to be enabled by default.)

Some of the keyboard shortcuts I've become accustomed to no longer function in any scheme:

  • Ctrl+Shift+Del - used to delete the entire content of the current query window
  • F4 - Object Search has been dropped (now opens properties)
  • F8 - now does nothing (used to toggle object explorer pane)
  • F6 - no longer toggles through messages / execution plan, only between query window and results

Some more information about Object Search (F4). There are other ways to obtain this information, such as the new Edit / Find and Replace menu option in Management Studio. And while it may not be as elegant, you can whip up quick queries against the metadata INFORMATION_SCHEMA views or the system catalog views, e.g.

USE MASTER
GO
 
SELECT
    ROUTINE_NAME,
    ROUTINE_DEFINITION
FROM
    INFORMATION_SCHEMA.ROUTINES
WHERE
    ROUTINE_DEFINITION LIKE '%Sales%'
 
SELECT
    OBJECT_NAME(object_id),
    OBJECT_DEFINITION(object_id)
FROM
    sys.sql_modules
WHERE
    PATINDEX('%Sales%', OBJECT_DEFINITION(object_id)) > 0

Some caveats, of course, such as the fact that a procedure over 8,000 characters is going to occupy multiple rows in the INFORMATION_SCHEMA view, and an outside chance that the word you are searching for straddles the rows (which will prevent the match from occuring). For a workaround, see http://www.aspfaq.com/2037.

© 2004-2010 Aaron Bertrand, All Rights Reserved. SQL Server 2005, of course, belongs to Microsoft.