How to Configure Cursor SQL Server Prevent Delete
You set up cursor sql server prevent delete rules by assigning a read-only database role to the agent user. You can also deny write rights on specific tables in the database. Teams often connect AI coding tools to local or test databases with broad admin credentials. When an agent uses a shared owner account, one bad prompt can wipe out whole tables. Giving the coding tool its own restricted login stops accidental row loss before it starts. How to set up cursor sql server prevent delete roles
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 cursor sql server prevent delete rules by assigning a read-only database role to the agent user. You can also deny write rights on specific tables in the database. Teams often connect AI coding tools to local or test databases with broad admin credentials. When an agent uses a shared owner account, one bad prompt can wipe out whole tables. Giving the coding tool its own restricted login stops accidental row loss before it starts.
How to set up cursor sql server prevent delete roles
SQL Server separates server logins from individual database users. A login lets a person or tool enter the server instance itself. A database user serves as the identity of that login inside one specific database. When a user needs to reach many databases, admins create a login in the master database first. When a tool only needs one database, admins can create a contained database user with its own password. To enable this option, an admin must turn on contained database settings on the server and database.
Once you create the database user for your AI tool, you assign fixed database roles to control its actions. Fixed database roles have set permissions that admins cannot change. Adding the user to the fixed data reader role lets it read all data from all user tables and views. You should keep the agent out of the fixed data writer role. Members of that writer role can add, delete, or change data across all user tables. You must also avoid the fixed database owner role. Database owners can run all maintenance tasks and can even drop the entire database.
Sometimes an AI coding assistant needs to insert test records or update rows without removing anything. Fixed roles apply to all user tables at once and group inserts, updates, and deletes together. If you add a user to the deny data writer role, the user cannot add, change, or delete any data. To block only row removal while allowing inserts, admins skip the broad writer role. Instead, they grant select and insert rights on target tables and deny delete rights to that database user. In SQL Server, an explicit deny rule overrides a grant rule on the same object.
What native database roles solve and what they miss
Native database roles and table permissions do a great job of blocking destructive commands at the storage engine level. When the coding agent connects through a database tool or runs a script, the server checks its user role. If the agent tries to remove rows without permission, the database engine rejects the statement right away. This native setup works well when every developer and every AI tool uses a dedicated, locked-down login.
Still, static database roles only decide who logs in and which broad object rights that account holds. They do not inspect what individual statements or commands try to do while in flight. In real work, developers often need to run schema updates or fix broken data from the same workspace. If a developer puts their own high-privilege credentials into the agent settings, the database cannot tell them apart. To the server, a destructive command from an AI loop looks just like a planned command from a human engineer.
SQL Injection Prevention + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why static credentials create risks for AI coding tools
AI coding tools reach databases through protocol servers or built-in shell tools that run terminal commands. Storing static connection strings on developer laptops spreads long-lived passwords across local text files. If a developer switches from a read-only account to a writer account for a quick fix, the safety net vanishes. Native roles also do not rewrite sensitive fields in query results, such as emails, phone numbers, or card numbers. When an agent runs a broad read query, raw customer records flow straight into the model context.
Static roles also leave gaps when an agent does need temporary write access to clean up a single test record. Granting delete rights for five minutes requires a manual role change by an admin and another change to revoke it. Without per-statement checks or human approval prompts on risky queries, teams must choose between slow manual tickets and risky standing access.
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 sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.
With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.
Frequently asked questions
Can a fixed database role block only delete statements in SQL Server?
No, fixed database roles cannot block only delete statements while keeping insert and update rights active. The fixed data writer role and the deny data writer role bundle add, change, and delete actions together. To stop only deletes, you must deny the delete permission on the specific tables or schemas.
Should Cursor use a server login or a contained database user?
A contained database user is a good choice when the coding agent only needs to reach one database. It stays inside that single database and does not need a login in the master database. If the agent must query many databases on the same instance, a standard server login is more common.
Why is the fixed data reader role not enough to protect sensitive data?
The fixed data reader role lets the user read all rows from every user table and view in the database by default. While it stops the agent from deleting rows, it still exposes emails, phone numbers, and national IDs in query results. You need data masking to rewrite matched fields in results before they reach the coding tool.
Related guides
In this post