---
title: "Database Read Query Step"
url: "https://docs.robotiq.ai/en/article/database-read-query-step"
language: "en"
last_updated: "2025-12-24T15:10:06.575Z"
---

# Database Read Query Step

The Database Read Query step runs a query on a specific database or data file. It saves the results into variables you set up. Use this step to get data from outside sources in your automated tasks.

## What You'll Need

-   Access to a database or data file.
-   The right connection string for your data source.
-   The correct database provider installed on the computer running the Robotiq.ai robot.

## How to Use the Database Read Query Step

This step lets you connect to a database, run a query, and save the results.

### Step 1: Add the Database Read Query Step

1.  Drag the "Database Read Query" step into your process flow.

### Step 2: Set Up Input Parameters

1.  **Connection String:** Type in an existing variable name or the direct connection string. This string tells Robotiq.ai how to connect to your database.
2.  **SQL Query:** Type in an existing variable name or the SQL query you want to run. This query tells the system what data you want to get.

### Step 3: Set Up Output Parameters

1.  **Result DataTable:** Type in a new or existing variable name of type "Datatable." This variable will hold the data your SQL query returns.
2.  **Column Count Variable Name:** Type in a new or existing variable name of type "Integer." This variable will hold the number of columns in your result datatable.
3.  **Row Count Variable Name:** Type in a new or existing variable name of type "Integer." This variable will hold the number of rows in your result datatable.

## Parameters Explained

**Step Name** (Optional)

-   A custom name for this step in your process.
-   Example: `ReadCustomerData`
-   Use this to make your process flow easier to understand.

**Connection String** (Required)

-   Tells the system the data source and connection details.
-   Example: `Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;`
-   You need the right provider installed on your system for the connection to work.

**SQL Query** (Required)

-   The SQL statement to run.
-   Example: `SELECT * FROM Customers WHERE City = 'New York'`
-   This query tells the system what data you want to get.

**Result DataTable** (Required)

-   A variable that holds the query results as a table.
-   Example: `customerDataTable`
-   This variable will be empty if your query does not return any data.

**Column Count Variable Name** (Required)

-   An integer variable that holds the number of columns in the `Result DataTable`.
-   Example: `customerColumnCount`
-   This helps you understand how the returned data is set up.

**Row Count Variable Name** (Required)

-   An integer variable that holds the number of rows in the `Result DataTable`.
-   Example: `customerRowCount`
-   This tells you how many records your query returned.

## Common Issues

**Problem:** The connection string isn't working. **Solution:**

1.  Check the connection string for typos.
2.  Make sure the right database provider is installed on the machine running the Robotiq.ai robot.
3.  Check network access to the database server.

**Problem:** The SQL query isn't returning the results you expect. **Solution:**

1.  Test your SQL query directly in a database client to make sure it works.
2.  Check for mistakes in your query's wording.
3.  Make sure the database has the data you expect.

## Related Articles

-   [Define Variable Step](https://docs.robotiq.ai/en/article/define-variable-step) - Learn how to create variables for your connection strings, queries, and results.
-   [Set Variable Value Step](https://docs.robotiq.ai/en/article/set-variable-value-step) - Use this step to give values to your variables before running the query.

## Need Help?

Can't find what you're looking for? Join the [Robotiq Community](https://community.robotiq.ai/home/) to get help from other users and the Robotiq team.

![](https://cdn-assets.productfruits.com/18069b5a-cb4c-46e8-98f5-73689b9afaec)

![](https://cdn-assets.productfruits.com/3cce2a3b-512e-4d53-a86b-d84f08e602dc)
