Dela via


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.

Note

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