Bagikan melalui


SQL Editor

Use the SQL Editor to edit existing stored procedures, functions, triggers, and SQL scripts. This window opens when you open any of those objects. If you want to create a new SQL statement to run against your data source, use the SQL Pane of Query Designer.

The integrated editor in Visual Studio provides many useful SQL text-editing features, including:

  • Color coding of SQL keywords to minimize syntax and spelling errors. This color coding is sensitive to many SQL dialects based on the type of database, including PL/SQL, Transact-SQL, T-SQL7, and T-SQL8.

  • Generating skeletal stored procedures and triggers.

  • Providing useful editing functions, including cut, copy, paste, and dragging operations.

  • Changing the editor's behavior (by selecting Options from the Tools menu) to modify virtual spaces, word wrap, line numbers, and tab size.

  • Helping manage debugging breakpoints.

Note

The SQL Editor does not have IntelliSense prompting.

When editing SQL statements, certain statements are enclosed in a box surrounded by a thin line. This helps to visually break the code into command sections, and identifies blocks of statements that can be graphically designed using Query Designer. For more information on using Query Designer, see Designing Queries and Views.

For stored procedures, functions, triggers, and scripts added to a database project from Solution Explorer, SQL Editor provides advanced save options where you can select the encoding (such as Western European or Unicode – Codepage 1200) and line endings (such as current, Windows CR-LF, MacIntosh CR, or Unix LF).

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

Saving a Script

To save a script using the advanced options

  1. Create a new item, or open an existing one from Solution Explorer.

  2. From the File menu, choose Advanced Save Options.

  3. In the Encoding list box, choose the encoding option.

  4. In the Line endings list box, choose the line ending option.

  5. Click OK to save your script.

For more information on the features of the text editor, see Editor Convenience Commands and Features.

See Also

Reference

Code and Text Editor

Other Resources

Designing Queries and Views

Understanding Visual Database Tools

Reference (Visual Database Tools)