Use Transact-SQL Editor to Edit and Execute Scripts

The Transact-SQL Editor provides you with a rich editing and debugging experience when you are working with scripts. It is invoked when you use the View Code contextual menu to open a database entity in a connected database or a project. It is also automatically opened when you use the New Query contextual menu from the SQL Server Object Explorer, or add a new script object to a database project.

If you are not connected to a database, but want to execute a query against it, you can also use the New Query Connection dialog box in the SQL -> Transact-SQL Editor menu option to connect to a database and launch the Transact-SQL Editor.

The Transact-SQL Editor contains a main T-SQL pane where you can write and edit Transact-SQL scripts. The editor supports IntelliSense as well as color coding of syntax to improve the readability of complex statements. It also supports find and replace, bulk commenting, custom fonts and colors, and line numbering. You can also change the database which the script in the editor will be executed against. For more information, see How to: Clone an Existing Database. The Results pane displays query results in a grid or text. You can also redirect query results to a file. The Message pane displays errors, warnings, and informational messages returned when a script is run. When client statistics is enabled, the Statistics pane displays information about the query execution grouped into categories. The Execution Plan pane displays the data retrieval methods chosen by SQL Server, and shows the execution cost of specific statements and queries.

In This Section

Topic Description
How to: Outline and Add Snippets to Transact-SQL Script Use the Snippet Picker to insert ready-made Transact-SQL code to your query.
How to: Navigate Between Scripts Use Go-To-Definition and Find All Reference to navigate between scripts.
How to: Use Rename and Refactoring to Make Changes to your Database Objects Rename an object across all scripts and preview any changes.
How to: Execute a Partial Query Highlight a specific segment of the script and execute it as a single query.
How to: Debug Stored Procedures Create and debug a Transact-SQL stored procedure by stepping into it.
Analyze Script Performance Use execution plans, client statistics and code analysis to determine whether you can improve performance of your query, stored procedures, or scripts.

See Also

How to: Create New Database Objects Using Queries