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: 

  1. 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.

  2. Drag the Microsoft SQL Server - Execute a query action to the point in the workflow when you want to execute a query.
  3. Click the Microsoft SQL Server - Execute a query action.
  4. Select a Connection. If you do not have a connection, see Add a connection.

  5. 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.

  6. 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.

  7. To add a parametrized query execution, in Query parameters, click Add SQL query parameters.
    1. Add a Parameter name and Value.
    2. 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>

  8. 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.

For more information on the fields and buttons, see Microsoft SQL Server - Execute a query fields and settings.