---
schema_version: "1"
id: 5f883f8f0f2767d05b7a6c542585b2e2a911bba2714bb0c75f4690728e0c6618
title: Create a Custom SQL Retriever
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/data/264-0-0/c360_a_ai_customsql_retriever_create.md
canonical_url: https://help.salesforce.com/s/articleView?id=data.c360_a_ai_customsql_retriever_create.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 140e33dbdc8b333e4cf51bb311237c8374e3d59aa93994cf8de751c46e97b733
description: Use a custom SQL retriever to query Data 360 objects using a SQL statement. To build your query, select an object, write a SQL query, specify parameter values, and configure citations. Review and run your query to validate accurate results before you save and activate the retriever.
products:
  - Data 360
release: "264"
---
# Create a Custom SQL Retriever

Use a custom SQL retriever to query Data 360 objects using a SQL statement. To build your query, select an object, write a SQL query, specify parameter values, and configure citations. Review and run your query to validate accurate results before you save and activate the retriever.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>All Editions</strong> supported by Data 360. See <a href="https://help.salesforce.com/s/articleView?id=data.c360_a_dc_editions.htm&amp;language=en_US" target="_blank">Data 360 edition availability</a>.</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:left;vertical-align:top;" id="d33092e61">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d33092e61 ">To manage retrievers or versions in AI Models (create, edit, test, and
              delete)</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d33092e61 ">
              <p>Allow users to manage models in AI Models </p>
              <p>OR</p>
              <p style="margin-bottom:0;">Data Cloud Architect
                permission set</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d33092e61 ">To access data with retrievers</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d33092e61 ">
              <p>For the Knowledge object: read access to the object AND Allow View Knowledge
                app permission. </p>
              <p style="margin-bottom:0;">For all other standard objects: read access to the object AND
                appropriate sharing rules. For more information see, <a href="https://help.salesforce.com/s/articleView?id=platform.admin_sharing.htm&amp;type=5&amp;language=en_US" target="_blank"><u>Set Your Internal Organization-Wide Sharing
                    Defaults</u></a>.</p>
            </td>

          </tr>
        </tbody>
      </table>

## Select a Retriever Type and Data Space

1. In AI Models, select **Retrieve**, then **New Retriever**.
2. Select **Custom SQL Retriever** as the retriever type. Click **Next**.
3. Select the data space that contains your data. Click **Next**.

## Define Retriever Search Query

1. In the Query tab, browse the list of objects and select an object.
2. Write a SQL query in the query editor.
3. Alternatively, select **Generate Query** to generate a query based on an existing search index. Configure your retriever options such as the data model object, search index configuration, pre-filters, and number of results to return.
4. Specify the parameter values for the query, such as the main search string and any default values.
    
    The retriever substitutes these values at run time to help with testing and evaluation.
5. Review your SQL query for errors and suggestions.

## Run and Activate a Custom SQL Retriever

1. To test your SQL query, click **Run**.
2. Validate the results from your SQL query.
3. Optionally, configure the number of results to return and citations settings in **Retriever Configuration**.
4. To review retriever details, click **Next**.
    
    Save your Custom SQL Retriever.
5. Activate the retriever.

**Generate Custom SQL Query**

![The Generate Query Modal allows you to select a data model object and search index. You can customize the configuration to include records that match a dynamic filter condition.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-data-data_cloud-264-0-0-production-enus/f3569962-3c9b-4f83-9d0c-b6a574e785da/data_cloud/images/retrieve_customsql_generate_query.png)

**Custom SQL Retriever Details**

![After you save a Custom SQL Retriever, the details page displays your retriever configurations, including the fields returned, number of results returned, and the SQL query.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-data-data_cloud-264-0-0-production-enus/f3569962-3c9b-4f83-9d0c-b6a574e785da/data_cloud/images/retrieve_customsql_details.png)

After you activate the custom SQL retriever, use it in Prompt Builder, Flow, and Agents.

#### See Also

- [_Salesforce Help_:Ground with Knowledge Using Retrieval Augmented Generation](https://help.salesforce.com/s/articleView?id=ai.prompt_builder_ground_rag.htm&language=en_US)
- [_Salesforce Help_: Search for AI, Automation, and Analytics](https://help.salesforce.com/s/articleView?id=data.c360_a_search_index_ground_ai.htm&type=5&language=en_US)