Skip to main content Skip to complementary content

Creating and storing SQL queries

From the Profiling perspective, you can query and browse a selected database using the SQL Editor and then to store these SQL queries under the Source Files folder in the DQ Repository tree view.

You can then open the SQL Editor on any of these stored queries to rename, edit, or execute the query.

Before you begin

You have selected the Profiling perspective.

Procedure

  1. In the DQ Repository tree view, expand Libraries.
  2. Right-click Source Files and select New SQL File from the contextual menu.
    Contextual menu of the Source Files folder.

    The New SQL File dialog box is displayed.

  3. In the Name field, enter a name for the SQL query you want to create and then click Finish to proceed to the next step.
    The SQL Editor opens on the new SQL query.
    Overview of the SQL Editor.
    If the Connections view is not open, use the combination Window > Show View > Data Explorer > Connections to open it.
  4. Enter your SQL statement in the SQL Editor.
  5. From the Choose Connection list, select the database you want to run the query on.
    Location of the Choose Connection drop-down list.
  6. On the SQL Editor toolbar, click Execute SQL to execute the query on the defined base tables.
    Data rows are retrieved from the defined base tables and displayed in the editor.
    Example of data rows displayed in the SQL Editor.
    A file for the new SQL query is listed under Source Files in the DQ Repository tree view.
  7. Right-click a SQL file and from the context menu select an action to perform.
    • Open: open the selected Query file.
    • Duplicate: create a copy of the selected Query file.
    • Rename SQL File: open a dialog box where you can edit the name of the query file.
    • Open in Data Explorer: open in the data explorer the SQL editor on the selected query file.
    • Delete: delete the query file.

      The deleted item will go to the Recycle Bin in the DQ Repository tree view. You can restore or delete such item by right-clicking the item. You can also empty the recycle bin by right-clicking it.

    Information noteNote:
    • When you open a query file in the SQL Editor, make sure to select the database connection from the Choose Connection list before executing the query. Otherwise the run icon on the editor toolbar will be unavailable.
    • When you create or modify a query in a query file in the SQL Editor and try to close the editor, you will be prompted to save the modifications. The modifications will not be taken into account unless you click the save icon on the editor toolbar.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!