How to Configure n8n SQL Server Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an n8n sql server prevent delete rule, restrict the database user role. You must remove delete rights from the account that your workflow uses to log in. Many teams start by giving their workflow an admin account to move fast. That broad role lets a bad workflow or AI agent wipe out production tables. A safe setup pairs strict database roles with statement checks before queries run. How to set up n8n sql server prevent delete roles SQL Server controls database actions through logins

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.

To set up an n8n sql server prevent delete rule, restrict the database user role. You must remove delete rights from the account that your workflow uses to log in. Many teams start by giving their workflow an admin account to move fast. That broad role lets a bad workflow or AI agent wipe out production tables. A safe setup pairs strict database roles with statement checks before queries run.

How to set up n8n sql server prevent delete roles

SQL Server controls database actions through logins, database users, and fixed roles. A database user is the identity of a login when it connects to a database. For access to many databases on an instance, teams create a login in master. For access to one or a few databases, a contained database user is an option. An admin must first turn on contained databases on the server and the database.

Once the user exists, you must pick the right fixed database roles. You cannot change the permissions assigned to fixed database roles in SQL Server. Many teams use the owner role by mistake during early tests. Members of the owner role can do all setup and maintenance tasks. They can even drop the whole database in SQL Server.

If your n8n workflow only reads data, assign the data reader role. Members of the data reader role can read all data from all user tables. They can also read from all views without having write or delete rights. If the workflow must never change data, also add the deny data writer role. Members of the deny data writer role cannot add, change, or delete any data.

Sometimes an n8n workflow needs to insert or update rows without deleting anything. The fixed data writer role lets users add, delete, or change data in all tables. Because fixed roles cannot change, the data writer role is too broad here. Instead, you must grant insert and update rights while denying delete rights on target tables.

How n8n workflows and AI agents run SQL queries

In n8n, workflows run database queries through standard nodes or through an AI Agent node. The AI Agent node builds an agent from a chat model and connected tools. The agent decides which tools to call to complete a task. You must connect at least one tool sub-node to an AI Agent node. Recent versions of n8n run all AI Agent nodes as a Tools Agent.

Teams can attach a Call n8n Workflow Tool or a Custom Code Tool to query SQL Server. They can also attach an HTTP Request Tool or use a registry of MCP servers. When an AI agent writes its own SQL queries, it can make mistakes. A prompt error can tell the agent to delete rows instead of updating them. If the database account has delete rights, SQL Server will run that command right away.

SQL Injection Prevention + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native SQL Server roles decide who can log in and which actions a user can run. Denying delete rights stops an n8n workflow from removing rows in those tables. This is a strong first step for any team running automated workflows.

Still, static database roles leave big operational gaps open during daily work. First, your n8n app still holds a static password to log in to SQL Server. Anyone who can read the n8n credential store can take that password. Second, a role that allows updates can still cause harm without deleting a single row. A bad update query with no filter can overwrite every row in a table.

Third, database roles do not hide sensitive data inside the rows that n8n reads. When a workflow reads a table, it pulls raw emails, phone numbers, and card numbers. Those sensitive fields then flow into workflow logs or out to external chat models. Native roles cannot rewrite matched fields in results or pause risky queries for human review.

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

Can I use the SQL Server data writer role and still block deletes?

The fixed data writer role grants add, change, and delete rights on all user tables. To block deletes while allowing inserts, you must explicitly deny delete permissions on your tables.

Should I use a contained database user for my n8n workflows?

A contained database user is a good choice when n8n only needs one database. It keeps the user and password inside that database instead of the master database.

Why do AI Agent nodes in n8n need extra database protections?

An AI Agent node lets the chat model decide which tools to call and run. If the model generates a bad query, only strict database rules can stop data loss.

The query runs. The emails stay hidden.