Microsoft SQL Server - Execute a query
Use the Microsoft SQL Server - Execute a query action A tool for building the processes, logic, and direction within workflows. to run queries in a database you specify. A query can be a request for data or for action.
For example, you want to generate a directory of your customers' email addresses. To achieve this, you need to retrieve the email addresses from your company database. By using the Microsoft SQL Server - Execute a query, you can retrieve these data, store them in variables, and then insert in a Generate document action.
For more information about Microsoft SQL server, go to Microsoft SQL server.
Configure the Microsoft SQL Server - Execute a query action
In the Designer page:
-
Click the Microsoft SQL Server action group in the action toolbox.
or
Find actions by browsing action groups, or by typing an action name or function in the Search field at the top of the action toolbox.
- Drag the Microsoft SQL Server - Execute a query action to the point in the workflow when you want to execute a query.
- Click the Microsoft SQL Server - Execute a query action.
-
Select a Connection. If you do not have a connection, see Add a connection.
- In SQL script, type concatenated queries, separated by semicolons, to run on your database. Do not use single quotations; instead, for parametrized queries, add query parameter key names and values (next step).
SQL script example: SELECT * FROM [Customers]
For more guidance on SQL keywords and syntax, see SQL Keywords Reference.
- To add a parametrized query execution, in Query parameters, click Add SQL query parameters.
- Add a Parameter name and Value.
- Click Add SQL query parameters to add more parameter names and values.
Example:SELECT * FROM [Customers] WHERE Name = @name
Parameter name = @name
Value = <Customer_Name>
- In Column to retrieve, type the database column that contains the values you want to retrieve. For example, "Email address". This field is required for SELECT queries.
Caution: Make sure to first configure your database's firewall to allow your workflow to connect to your database. For more information on source IP addresses you can use, see Source IP addresses for workflows.
For more information on the fields and buttons, see Microsoft SQL Server - Execute a query fields and settings.
To run workflows that connect to SQL databases or related systems, first configure its firewall rules to allow traffic from potential source IP addresses for these workflows. If firewall rules are in place but not configured to allow these IP addresses, then contact does not occur and the workflow fails.
For instructions on SQL Server firewall configuration, see the Configure the Windows Firewall to Allow SQL Server Access Microsoft article or, for SQL Server on Windows Azure, see the Creating Microsoft SQL Server Connection to SQL Azure from Nintex Automation CloudNintex Community article.
Potential source IP addresses for workflows:
US region | EU region | AU region |
---|---|---|
|
|
|
Field |
Description |
Variable types |
---|---|---|
The Microsoft SQL Server connection to use for the query. |
(n/a) |
|
SQL script |
The concatenated queries, separated by semicolons, that will run on your database. Do not use single quotations; instead, for parametrized queries, add query parameter key names and values. SQL script example: SELECT * FROM [Customers] For more guidance on SQL keywords and syntax, see SQL Keywords Reference. |
Text, Decimal, Integer, Boolean, DateTime, Collection |
Query parameters | Adds a parametrized query execution. Click Add SQL query parameters and add a Parameter name and Value. | Text, Decimal, Integer, Boolean, DateTime, Collection |
Column to retrieve | The database column that contains the values you want to retrieve. For example, "Phone numbers". This field is required for SELECT queries. | Text, Decimal, Integer, Boolean, DateTime, Collection |
Result |
Stores the result of the action in an object with the following variables:
This variable is very useful especially if your workflow should know how many values were retrieved by the action. |
Object |