Creating SQL and XQuery statements in the SQL editor by using a database connection

You can use a database connection in the Database Explorer view to create SQL and XQuery statements in the SQL editor.

The SQL editor supports any statement that can be run by the database to which you are connected. If you save the statement, it is stored in a file with the extension .sql.

Prerequisites: Before you create an SQL or XQuery statement by using a database connection:
  • Define a database connection in the Database Explorer view.
  • If you plan to save the statement, create the project in which to store the statement.
Restriction:
  • If you want to reopen the SQL or XQuery statement in the SQL editor or the SQL statement in the SQL builder, save the statement in a data project.
  • If you save the statement in a data development project, the project must be associated with a database that contains the database tables that you use in the statement. Otherwise, you cannot run the statement successfully.

To create an SQL or XQuery statement in the SQL editor by using a database connection:

  1. Open the Data perspective.
  2. In the Database Explorer view, expand the database connection.
  3. Right-click the database connection or the database, and then click New SQL or XQuery Script on the pop-up menu.
  4. In the New SQL or XQuery Script window, type a name for the statement.
  5. Under Edit using, leave SQL editor selected.
  6. Click OK. The statement opens in the SQL editor.
  7. Complete the SQL or XQuery statement.
  8. Optional: To insert the code pattern of a template into your statement, at the insertion point, type the first few characters of the template name, press Ctrl + Space, and then select the template in content assist.
  9. Optional: To format your SQL or XQuery code, right-click in the editor, and then click Format SQL on the pop-up menu.
  10. Save the statement.
  11. In the Save As window, select the project in which to save the statement, and then click OK. If you select a data project, the statement is added to the SQL Scripts folder of the selected project.
Related concepts
SQL editor
Related tasks
Changing the SQL statement terminator
Inserting code templates in SQL and XQuery statements

Feedback