Editing Scripts and Files in SQL Server Management Studio
You can use one of the Microsoft SQL Server Management Studio editors to edit a Transact-SQL, MDX, DMX, or XML/A script, or to edit an XML or plain text file. Each editor is supported by a language-specific service that colors keywords, and checks for syntax and usage errors. The Database Engine Query Editor includes a Transact-SQL debugger that you can use to help fix problems in Transact-SQL code.
Each editor provides features to simplify the process of writing and editing queries. These features vary depending on your programming language and the options set for the editor in the Options dialog of the Tools menu.
There are several ways to open an editor:
On the Standard toolbar in SQL Server Management Studio, click the New Query button. A Query Editor window is opened using the currently connection.
On the Standard toolbar, click the button associated with the type of connection you want, such as Database Engine Query.
From Solution Explorer, expand a folder, right-click an item within the folder, and then click Open or double-click the item or file.
From the File menu, point to Open, click File, and then choose a document.
From the File menu, point to New, click File, and then choose a query type.
If you share files with users at other sites that use distinct code pages, you should save your file with the appropriate Unicode code page to prevent errors when reading the file. Also, when saving files for UNIX or Macintosh, be sure to save your files with the appropriate document format. On the File menu, click Save As, Save with Encoding from the down arrow next to the Save button, and then choose Unix or Macintosh under Line Endings.
In This Section
Editor Convenience Commands and Features
Describes Editor features that help you administer your server or develop a database solution.
Navigating Code and Text
Explains how to navigate in the Editor.
How to: Drag and Drop Text
Explains how to drag and drop text.
Searching and Replacing
Explains how to search and replace in the Editor, including new features such as incremental search.
Code and Text Printing Issues
Describes how the font and color choices in the Editor may affect printing.
How to: Manage the Editor and View Mode
Explains how to change views in the Editor.
How to: Manage Code Formatting
Explains how to manage how SQL Server Management Studio formats your code, including features for automatically formatting code.
How to: Use the Properties Window in Management Studio
Describes property pages in SQL Server Management Studio.
How to: Change Font Color, Size, and Style
Describes how to customize the appearance of text in the Editor.
Describes the features of Microsoft IntelliSense, a technology that displays helpful information as you type code. IntelliSense is not available for all languages.
Using the Transact-SQL Debugger
Describes how to use the Transact-SQL debugger to find problems in Transact-SQL code and scripts.