# Creating and storing SQL queries

Available in...

* Big Data Platform
* Cloud API Services Platform
* Cloud Big Data Platform
* Cloud Data Fabric
* Cloud Data Management Platform
* Data Fabric
* Data Management Platform
* Data Services Platform
* MDM Platform
* Real-Time Big Data Platform

From the Profiling perspective of Talend Studio, 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.

   ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/SQLQuery_Create.png)
2. Right-click Source Files and select New SQL File from the contextual menu. 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.

   ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/SQLQuery_Create2.png)

   If the Connections view is not open, use the combination Window &gt; Show View &gt; Data Explorer &gt; 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.

   ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/SQLQuery_Create3.png)
6. On the SQL Editor toolbar, click ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/execute.png) to execute the query on the defined base table(s).

   Data rows are retrieved from the defined base table(s) and displayed in the editor.

   ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/SQLQuery_Create4.png)

   A file for the new SQL query is listed under Source Files in the DQ Repository tree view.

   ![](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/SQLQuery_Create5.png)
7. Right-click an SQL file and from the contextual menu select:
   | Option | To... |
   | --- | --- |
   | 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<br>file |
   | Open in Data Explorer | open in the data explorer the SQL editor on the selected query<br>file |
   | Delete | delete the query file<br><br>Information noteNote: The deleted item will go to the<br>Recycle Bin in the DQ<br>Repository tree view. You can restore or delete such<br>item via a right-click on the item. You can also empty the recycle<br>bin via a right-click on 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.