Microsoft SQL · Query — Run a query against your database — runs SQL you write against your own SQL Server or Azure SQL database.

Who can do this

Workspace Admins and Editors. Microsoft SQL is a paid-plan service: On any paid plan. You can build and test it now; publishing asks you to upgrade.

Before you start

A Microsoft SQL connection in this workspace, with a connection string that has a User ID and Password of your own, for a server on the public internet.

Steps

  1. Select +, then in Apps select Microsoft SQL, or search SQL.

  2. Choose the Connection.

  3. In Query, write the SQL. It starts with an example:

    select id, status, total
    from orders
    where phone = @phone
    

    Name each value @like_this and give it under Parameters.

  4. Under Parameters, select Add a field for each @name: the name — @phone — and its value, usually {{ }} from an earlier step. Always parameters, never text glued into the query.

  5. Select Run this step, then check Output.

Output

Field What it is
count How many rows came back.
rows The rows, each by its column names.
affected How many rows an insert, update or delete changed. 0 for a select.
note Only when cut: Only the first 1,000 rows are kept.

Good to know

  • {{ }} is never allowed inside the query. Values go in Parameters.
  • A parameter keeps its type.
  • 15 seconds to connect, 30 seconds to run.
  • Runs once per item.
  • Paid: a live run on a plan without paid services is skipped; tests work on any plan.

If something goes wrong

What the run says Why What to do
SQL Server refused: … SQL Server refused the query or the sign-in. Read the reason.
Put values from earlier steps in Parameters — @name in the query — never in the query itself. The query contains {{ }}. Move each value into Parameters.
Use a SQL Server user and password in the connection string — User ID=…;Password=… — and no Authentication or Integrated Security setting. The string signs in another way. Replace it with a SQL Server user and password.
The connection string has no User ID. Replace it on Connections with one that has a SQL Server user and password. No user. Replace it.
The connection string names a Failover Partner, which workflows cannot use. Replace it on Connections with the server's own address. A failover partner is set. Remove it.
The connection string is not one SQL Server understands. Replace it on Connections. The string is malformed. Replace it.
… is not on the public internet, so workflows cannot reach it. The server is private. Use a server on the public internet.
The query is empty. Query is empty. Write the query.