How to Configure n8n SQL Server Credentials
You set up n8n sql server credentials by creating a dedicated database user first. Then you store that user account and password inside your n8n workflow settings. Many teams rush this step and reuse an admin login to save time. When a workflow uses a broad role, one bad query can alter or drop production data. This guide explains how database logins work and how to scope permissions for automation. How to set up n8n sql server credentials and database roles A secure setup starts inside your
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.
You set up n8n sql server credentials by creating a dedicated database user first. Then you store that user account and password inside your n8n workflow settings. Many teams rush this step and reuse an admin login to save time. When a workflow uses a broad role, one bad query can alter or drop production data. This guide explains how database logins work and how to scope permissions for automation.
How to set up n8n sql server credentials and database roles
A secure setup starts inside your database engine before you touch the workflow tool. In SQL Server, a database user is the identity of a login upon entry. Database admins choose between two main ways to create this user account. When an account needs access to many databases on one instance, admins create a login in the master database. They then map a SQL user to that central login.
If a workflow only needs one or a few databases, another option exists. Admins can create a contained database user with its own password. This contained user stays inside the target database and does not link to master. Before doing this, an admin must turn on contained databases on the server and database. In total, the database engine supports thirteen different types of database users.
After creating the user, you must assign its permissions through fixed database roles. Every role, including the public role, holds the basic permission to connect. You cannot change the base permissions that belong to fixed database roles. For read-only workflows, admins add the user to the fixed data reader role. Members of this role can read all data from all user tables and views.
If a workflow must update rows, admins use the fixed data writer role. That role lets the user add, delete, or change data across all user tables. You can also block actions with explicit deny roles for reading or writing. Members of the deny data reader role cannot read any user tables, views, or metadata. Members of the deny data writer role cannot add, change, or delete any table data.
Why broad roles create risks for automated workflows and AI agents
Teams often assign the fixed database owner role when testing a new workflow. A database owner can run all setup and maintenance tasks on that database. Even worse, that role can drop the entire database in SQL Server. Leaving an automated workflow on an owner role puts every table at risk.
Ephemeral Credentials + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
This risk grows when teams attach database tools to AI agents in n8n. The n8n AI Agent node builds an agent using a chat model and connected tools. You must attach at least one tool sub-node to an AI Agent node. During a run, the agent decides which tools to call to finish its task. Starting in version 1.82.0, all AI Agent nodes run as a Tools Agent.
To connect a database to an agent, teams often use a Call n8n Workflow Tool. They can also connect an HTTP Request Tool, a Custom Code Tool, or MCP servers. Once the workflow logs in, the database only checks the static role of that user. Fixed database roles apply across every user table in the database at once.
Native roles decide who logs in, not what each query does in flight. A data reader role lets a workflow read every table, including sensitive customer tables. It cannot rewrite matched fields like emails, phone numbers, card numbers, or national IDs. Likewise, a data writer role lets a buggy workflow delete rows from any user table. Native database credentials alone cannot inspect individual statements or require approval before risky runs.
Govern SQL Server queries and responses in flight
Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev is an open-source proxy that sits next to SQL Server as a sidecar for your SQL Server. It inspects TDS batches and parameterized queries in real time.
With hoop.dev guardrails and hoop.dev data masking, banned statements are refused with your message. Matched sensitive fields in supported result columns are masked in memory, and each decision is logged per listener. Check out the code on GitHub.
Frequently asked questions
Should I use a master login or a contained user for n8n workflows?
Use a contained database user when your workflow only needs one or a few databases. It keeps the password scoped to that database without needing a login in master. Use a master login only when the workflow must query many databases on one instance.
What happens if I give my n8n database user the owner role?
The fixed database owner role allows full maintenance and setup changes across the database. A user in this role can even drop the entire database in SQL Server. Always use narrower roles like the fixed data reader role instead.
Can the fixed data reader role hide sensitive columns from an n8n workflow?
No, the fixed data reader role grants read access to all user tables and views. You cannot alter the default permissions of a fixed database role to hide specific columns. To block all table reads, an admin must use the deny data reader role or custom permissions.
Related guides
In this post