How to Configure Codex SQL Server Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up codex sql server prevent delete controls by assigning a restricted database role. You can also create custom table rules that block delete actions for the agent login. Teams often link OpenAI Codex to a database using a shared developer account. If that account has broad rights, a bad prompt can wipe out production rows. A single misunderstood task can remove critical records in seconds. How to set up codex sql server prevent delete in native roles SQL Server uses logins and databa

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 codex sql server prevent delete controls by assigning a restricted database role. You can also create custom table rules that block delete actions for the agent login. Teams often link OpenAI Codex to a database using a shared developer account. If that account has broad rights, a bad prompt can wipe out production rows. A single misunderstood task can remove critical records in seconds.

How to set up codex sql server prevent delete in native roles

SQL Server uses logins and database users to control who enters a database. A database user is the identity of a login inside a specific database. Teams often create a login in the master database for broad server access. You can also make a contained database user with its own password. That contained user stays tied to one database after an admin enables the setting.

Once the user exists, you assign fixed database roles to limit its actions. The fixed reader role lets the user read all data from user tables and views. The fixed writer role lets a user add, change, or delete data in all tables. A deny writer role stops the user from adding, changing, or deleting any table data. Avoid the owner role, as it allows full maintenance and can drop the whole database. You cannot change the base permissions assigned to these built-in fixed database roles.

If an AI agent only needs to read data, the reader role works well. Sometimes the agent must insert new rows or update test data without deleting anything. Fixed roles cannot split insert rights from delete rights on their own. In that case, admins create a custom role and deny the delete permission on schemas. Deny rules override grant rules inside SQL Server except for top server admins.

What native roles solve and what they leave open

Native roles decide which user can log in and which coarse actions are allowed. If you deny delete rights, SQL Server rejects direct row removal from that user. This stops a simple delete query from wiping a table by mistake.

Still, static database roles do not inspect what individual queries do in flight. An agent with update rights can still set every column in a table to null. That action ruins the data just like a delete statement without triggering a role error. A user with reader rights can also pull every table row into the model context. That query exposes sensitive fields like emails, phone numbers, card numbers, and national IDs.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams also struggle to manage static database passwords stored on developer laptops. When an AI coding tool reads local files, it can find and use those keys. Database roles also treat every query from that user the same way. You cannot pause a single risky update for human approval while letting safe selects run. You also lack a clear log that links each SQL query to a specific user.

Why runtime query checks matter for AI agents

AI coding tools generate and run commands fast, often chaining several steps together. When an agent hits an error, it tries new ways to finish the prompt. If a delete fails, the agent might try an update or call a stored procedure. If that stored procedure has higher rights, the agent might still wipe the data.

Safe database work with AI agents requires looking at each statement before it runs. Teams need a way to block dangerous patterns while keeping normal work moving. Masking rules that rewrite matched fields in results also help protect sensitive user data. When emails or card numbers get rewritten in results, sensitive values stay out of prompts. Combining strict database roles with statement-level checks gives teams a much safer setup.

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 fixed database roles block deletes while allowing inserts?

No, the built-in writer role groups add, change, and delete permissions together. To block only deletes, you must assign custom permissions or explicitly deny delete rights.

Why is the database owner role risky for an AI coding agent?

The owner role can run all maintenance tasks and even drop the entire database. An AI agent with this role can destroy schemas and tables with one bad command.

Does blocking delete statements protect against all data loss?

No, an agent with update rights can still overwrite existing rows with blank values. You must also control update statements and stored procedures to prevent accidental data loss.

The query runs. The emails stay hidden.