Creating SQL and XQuery statements in the SQL and XQuery editor by using the Data Source Explorer toolbar

You can use the Data Source Explorer toolbar to create SQL and XQuery statements in the SQL and XQuery editor.

The SQL and XQuery 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.

Prerequisite: If you want 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 and XQuery editor or the SQL statement in the SQL Query 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 and XQuery editor by using the Data Source Explorer toolbar:

  1. Open the Data perspective.
  2. In the Data Source Explorer view, click the New SQL Script toolbar button.
  3. In the Select Connection Profile wizard, select the database that you want to connect to, and then click Finish.
  4. Specify the SQL or XQuery statement in the SQL and XQuery editor.
  5. 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.
  6. Optional: To format your SQL or XQuery code, right-click in the editor, and then click Format SQL on the pop-up menu.
  7. Save the statement.
  8. In the Save As window, provide the information about the SQL statement:
    1. Select the project in which to save the SQL statement. If you select a data project, the statement is added to the SQL Scripts folder of the selected project.
    2. Type a file name for the statement.
    3. Click OK

Feedback