---
title: "Creating a SQL Table Paragraph"
canonical: "https://docs.rubiconwater.com/space/RptNC/1979483200/Creating%20a%20SQL%20Table%20Paragraph"
format: markdown
---
> Macro (toc)

Use this report component to create tables from simple SQL queries.

> ℹ️ **Note**
> ℹ️ 
> ℹ️ If you need to use SQL Tables in your reports, contact Rubicon to discuss access to the appropriate Rubicon data dictionaries.

A SQL Table paragraph consists of a SQL query (defined on the Query tab) which is used to extract data from the database, and a report table (defined on the Table tab) which is used to present the data. The process for creating a SQL table paragraph is as follows:

1. Click  New Paragraph to open the Add Paragraph dialog and choose SQL Table. The New SQL Table screen opens
2. On the **General** tab, enter a name for the paragraph. This will identify the paragraph in the report structure pane.
3. On the **Query** tab, write your SQL query.
4. Click **Apply** to validate and save the query
5. Click the **Bind Data** button to bind selected columns to columns on the table tab. This extracts selected column names or aliases from your query, and binds them to report table columns.
  **Note**
  If your data columns were not bound check the following:
  - You clicked **Apply** to save the query before you clicked **Bind Data**.
  - Your query is valid SQL syntax for the database you are using. You will receive an error message if you attempt to bind data from an invalid or unsaved query.
6. On the **Table** tab, make any changes you need to your report table. See <u>[Working with Report Tables and Columns](https://rubiconwater.atlassian.net/wiki/spaces/RptNC/pages/1979744611)</u> for more information.
7. Click **Save** to save your changes.

# Using parameters in a SQL query

You can substitute parameter values in SQL queries by enclosing the parameter name in a pair of carets. For example ^MyParameter^. For object, attribute type and tag parameters, the value substituted is the integer primary key.

# SQL Query Tips

Note that editable reports are intended to read data. You cannot run report queries that make changes to the underlying data. For example, you cannot run INSERT or DELETE queries.

## SQL syntax variations

Rubicon applications can run on different types of database. Make sure that your report queries use appropriate SQL syntax for the database you are using.

## Parameter values

Note that, for object, attribute type and tag parameters, the substituted value depends on the context:

- In a SQL query, the value that is substituted is the primary key which is an integer.
- In a text field, the value substituted is the label, which is a string.

## Check data types

The default data type for report table columns is string. Cast the values to a number type if you need to order them as numbers or use them in calculations. You can cast within the query, or set the column data type in the **Table > Columns** tab.

---