N8n SQL Server Node

Published
Length
3 min read

Luis Felipe Dias

All posts

The n8n sql server node connects your workflows to Microsoft SQL Server databases. It lets engineers and AI agents read, add, or update records during a run. Teams use this node to automate reports, sync customer records, and answer data questions. When you pair workflows with AI agents, database security becomes a top priority. You must control both who logs in and what each query can touch. How the n8n sql server node works in practice In standard workflows, the n8n sql server node runs fi

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

The n8n sql server node connects your workflows to Microsoft SQL Server databases. It lets engineers and AI agents read, add, or update records during a run.

Teams use this node to automate reports, sync customer records, and answer data questions. When you pair workflows with AI agents, database security becomes a top priority. You must control both who logs in and what each query can touch.

How the n8n sql server node works in practice

In standard workflows, the n8n sql server node runs fixed queries on a schedule. An engineer sets up a database login and writes the query logic ahead of time. When a trigger fires, the node connects to the database and runs the task.

AI workflows work in a different way because the model chooses the next step. The n8n AI Agent node pairs a chat model with one or more tools. The agent decides which tools to call to complete a task on its own. You must attach at least one tool sub-node to an AI Agent node.

Starting in n8n 1.82.0, the old agent type setting is deprecated for new builds. Every AI Agent node now runs as a Tools Agent by default. Node version 1 with the old setting is removed in n8n 3.0. Also, the old SQL Agent only supported MySQL, SQLite, and Postgres data sources.

To let an agent query SQL Server, teams attach a tool to the agent. For example, n8n offers a Call n8n Workflow Tool and a Custom Code Tool. The agent can call a sub-workflow that runs the n8n sql server node. It can also connect through a registry of MCP servers or an HTTP Request Tool.

How SQL Server logins and roles limit access

Before any workflow runs, an admin must set up an identity in SQL Server. A database user is the identity of a login when it connects to a database. SQL Server supports 13 types of database users for different access needs.

If a workflow needs many databases on one server, a master login is common. If it only needs one database, a contained database user is an option. This user has a password and does not tie to a master login. An admin must enable contained databases on the server and the database first.

Kubernetes API Server Access + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Once the user exists, admins assign fixed database roles to control table access. Every database role, including the public role, has basic permission to connect. The permissions inside fixed database roles are locked and cannot be changed.

For read-only workflows, admins often add the user to the datareader role. Members of this role can read all data from all user tables and views. If an agent needs to write, the datawriter role lets it change user tables. Admins can also apply deny roles to block all reading or writing in tables. In contrast, the owner role can do all maintenance and even drop the database.

Why static database roles fall short for active sessions

Database roles are a good first step, but they have clear limits in production. A workflow node holds one static credential for every run and every user prompt. If you give that user the datareader role, it can read every user table.

Fixed roles do not stop an AI agent from reading sensitive columns inside allowed tables. When a query runs, raw emails, phone numbers, card numbers, and national IDs come back. Those details flow straight into the workflow logs and the chat model context. Data masking solves this by rewriting matched fields in results before the app gets them.

Static roles also lack per-query approval and fine audit trails for shared bot accounts. If twenty people trigger one agent workflow, the database only sees one shared SQL login. Placing a query control layer in front of the database closes this gap. It checks every query, blocks unsafe commands, and rewrites sensitive fields in real time.

Check SQL Server batches and results on the wire

SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can the deprecated n8n SQL Agent connect to SQL Server?

No, the deprecated SQL Agent only supported MySQL, SQLite, and Postgres data sources. Instead, use a current AI Agent node and attach a workflow or custom tool.

How do I make an n8n SQL Server login read-only?

Assign the database user to the fixed datareader role in SQL Server. You can also add the deny datawriter role so it cannot change any table data.

How does data masking protect SQL Server results in n8n?

Data masking inspects query results in transit and rewrites matched fields in results. It replaces sensitive fields like emails, phone numbers, and card numbers before n8n logs them.

The query runs. The emails stay hidden.