How to Configure n8n SQL Server Read Only Access
You set up n8n sql server read only access by creating a restricted database user. Then you add that user to the reader role and save the credentials in n8n. Teams often reuse broad database owner accounts to build workflows fast. That shortcut lets a broken workflow or an AI agent change or drop production tables. How to set up n8n sql server read only access Start by creating a dedicated identity inside your database server. In SQL Server, a database user represents the login identity insid
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 read only access by creating a restricted database user. Then you add that user to the reader role and save the credentials in n8n. Teams often reuse broad database owner accounts to build workflows fast. That shortcut lets a broken workflow or an AI agent change or drop production tables.
How to set up n8n sql server read only access
Start by creating a dedicated identity inside your database server. In SQL Server, a database user represents the login identity inside a specific database. If your workflows need many databases on one instance, create a login in the master database. Then map a database user to that login in each target database.
If n8n only needs one database, you can use a contained database user instead. A contained user has its own password and does not need a login in master. An admin must enable contained databases on the server and database first. Note that SQL Server supports thirteen different types of database users.
Next, grant read permissions using fixed database roles. The data reader role lets members read all data from all user tables and views. You can also add the user to the deny data writer role for extra safety. That role stops the user from adding, changing, or deleting table data. Remember that you cannot change the permissions built into fixed database roles.
Avoid using the database owner role for automation workflows. Members of the owner role can run any maintenance task and even drop the database. Once your read-only user is ready, store those credentials inside your n8n workflow settings.
How n8n workflows and AI agents run queries
Standard n8n workflows run the queries you define inside your database nodes. Many teams also build AI workflows using the n8n AI Agent node. The AI Agent node combines a chat model with one or more connected tool sub-nodes. The agent decides which tool to call to finish its task.
Every AI Agent node acts as a Tools Agent in recent n8n releases. To let an agent query SQL Server, teams attach a sub-workflow tool or custom code tool. You can also connect an MCP server tool from the n8n registry. When the agent triggers the tool, n8n runs the query using your stored SQL Server login.
Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native read-only roles solve and what they miss
Native database roles do a great job of blocking write commands at the server level. If an agent tries to delete rows, the database rejects the query right away. Your tables stay safe from accidental edits or destructive commands.
Still, a native database role only checks who logs in at the start. The data reader role allows reading every single user table and view in that database. It does not inspect individual SQL statements while they are in flight. A workflow or AI agent can still select sensitive columns across all tables.
That means raw emails, phone numbers, card numbers, and national IDs flow straight into n8n. If an AI agent runs the query, those fields get sent to your chat model. Native roles also share one static login across everyone who edits the n8n workflow. Database logs only show the shared n8n user, not which person or agent ran the query. To protect sensitive fields, masking rewrites matched fields in results before they reach the client.
Add runtime guardrails beside SQL Server
Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev runs beside the database as a sidecar for your SQL Server and checks TDS traffic without changing how clients log in.
With hoop.dev SQL Server controls, rules refuse banned statements before they run and can hold risky queries for human review. Matched sensitive values in supported result columns are masked before they reach the client. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.
Frequently asked questions
What is the difference between a SQL login and a contained user?
A standard SQL user maps to a server login stored in the master database. A contained database user has its own password inside the target database and needs no master login. Contained users work well when n8n only reads one or a few databases.
Does the SQL Server data reader role hide sensitive columns?
No, the fixed data reader role grants read permissions across all user tables and views. You cannot alter the permissions assigned to a fixed database role. Blocking specific columns or masking fields like card numbers requires extra controls.
Can the n8n AI Agent node query SQL Server directly?
The AI Agent node requires at least one connected tool sub-node to take actions. While built-in SQL agent tools target Postgres or MySQL, you can attach a Call n8n Workflow tool. That sub-workflow runs the SQL Server node using your read-only credentials and returns the results.
Related guides
In this post