Writing, Analyzing, and Editing Scripts with SQL Server Management Studio
SQL Server Management Studio includes language-specific code editors for editing Transact-SQL, MDX, DMX, XMLA, and SQL Server Compact Edition queries.
Features of the SQL Server Management Studio code editors include:
Templates that can be used to speed authoring of scripts for scripts for SQL Server, SQL Server 2005 Analysis Services (SSAS), and SQL Server 2005 Compact Edition. Templates are files that include the basic structure of the statements needed to create objects in a database.
Color coding of syntax to improve the readability of complex statements.
A graphical query designer for drag-and-drop creation of queries.
Presentation of query windows as either tabs in the document window, or in separate documents.
Presentation of query results in either a grid or text window or redirected to a file.
Display of result grids as separate tabbed windows.
Graphical display of Showplan information showing the logical steps built into the execution plan of a Transact-SQL statement. Management Studio uses XML Showplan for retrieving Showplan information from the SQL Server Database Engine when connected to SQL Server 2005 instances; however, it uses text information when connected to SQL Server 2000 instances.
A feature-rich text editing environment supporting find and replace, bulk commenting, custom fonts and colors, and line numbering. Some types of editors contain additional features like outlining and auto-complete.
SQLCMD Mode for executing scripts with operating system commands.
Because you are not starting SQLCMD from the command prompt, there are some limitations when running Query Editor in SQLCMD Mode. You cannot pass in command-prompt parameters such as variables, and, because the Query Editor does not have the ability to respond to operating system prompts, you must be careful not to execute interactive statements.
The query editors include the following windows:
- Query Editor. This window is used to write and execute scripts.
- Results. This window is used to view the results of a query. The window can display the results in grid or in text.
- Messages. This window displays information about how a query ran. For example, the Messages window will show any errors or the number of rows returned.
- Client Statistics. This window displays information about the query execution grouped into categories. When Include Client Statistics is selected from the Query menu, a Client Statistics window is displayed upon query execution. Statistics from successive query executions are listed along with the average values. Select Reset Client Statistics from the Query menu to reset the average.
The following table lists SQL Server Books Online topics related to the code editor.
Contains information about templates and creating custom templates.
Includes topics on features such as code outlining, line numbering, hyperlinks in comments, sguiggles, word wrap, and more.
Includes a list of the keyboard shortcuts available in the code editor.
Explains how to configure SQL Server Management Studio to open a designated code editor based on a file extension.
Contains links to pages that describe many configuration options for the code editor.
Describes how to customize the appearance of text in the code editor.
To access the SQL Server Management Studio Query Editor
On the File menu, click New, and then click File.
The New File dialog box appears.
Under Categories, click the type of query you want to create. For example, to create a Transact-SQL Query, click SQL Server Query.
In the Templates box, click the type of query you want to write. For example, to create a Transact-SQL query, click SQL Server Query.
The Connect to SQL Server dialog box appears.
In the Server instance list box, type or select your server name, and then click Connect.
The Query Editor window appears.
To view the code editor in full-screen mode
- In a code editor window, press SHIFT+ALT+ENTER, to toggle in and out of full-screen mode.