Using the Query Editor

With SQL Server 2005, the Query Editor carried on the legacy of SQL Server's Query Analyzer as the primary UI for database developers. In SQL Server 2008 and 2008R2, that experienced was enhanced and evolved. Now, with SQL Server 2012 it's an absolutely awesome product to work with!

Opening a Query Connecting to a Server

The Query Editor can maintain multiple open query documents and connections within the tabbed document area. Different queries may be connected as different users, which is useful for testing security. And the Query Editor can open and work with a .sql file even when not connected to a server.

When Query Editor first opens, it prompts for an initial login. To make further connections, use the File → New Connection menu command.

The New Query toolbar button opens a new Query Editor document. There's some intelligence in how it selects the current database for the new query. If the Object Explorer has focus before the New Query button is pressed, the new query connects to Object Explorer's currently selected database. If the Query Editor has focus, the new query opens to the same database as the Query Editor's current query.

You can also switch a query's connection to another server using the Query → Connection menu, the Change Connection toolbar button, or the Query Editor's context menu.

The query tab displays the most it can of the current SQL Server and database merged with the filename.

Tip
In some extreme cases, if SQL Server appears ...

Get Microsoft SQL Server 2012 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.