How to Configure Vercel AI SDK SQL Server Prevent Delete
To set up a vercel ai sdk sql server prevent delete workflow, restrict database roles. You must remove delete rights from the database user that runs your AI tool calls. Many teams give their AI app a broad database role during early testing. If that role can write data, a bad prompt can wipe out production tables. Scoping down the database user stops the model from removing rows by mistake. How to set up vercel ai sdk sql server prevent delete rules In this framework, the model writes querie
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 a vercel ai sdk sql server prevent delete workflow, restrict database roles. You must remove delete rights from the database user that runs your AI tool calls. Many teams give their AI app a broad database role during early testing. If that role can write data, a bad prompt can wipe out production tables. Scoping down the database user stops the model from removing rows by mistake.
How to set up vercel ai sdk sql server prevent delete rules
In this framework, the model writes queries and passes them to a tool function. Your app then runs those queries using a database user. In SQL Server, a database user is the identity of a login inside a database. When an app needs many databases on an instance, teams use a standard login. That login sits in the master database. For one or a few databases, teams can use a contained database user instead. A contained user has a password and does not tie to a master login. An admin must enable contained databases on the server and the database first.
Once you pick one of the 13 user types, you must set its role. Fixed database roles have strict permission sets that you cannot change. If your AI agent only needs to read data, use the data reader role. Members of this role can read all data from all user tables and views. Do not use the data writer role if you want to block deletes. The data writer role can add, delete, or change data in all user tables. Never give an AI tool the owner role. That role can run all maintenance tasks and can even drop the entire database.
Where native database roles fall short for AI agents
Native roles work well when an AI agent only needs to read tables. You can also use a deny data writer role to block all changes. Members of that role cannot add, change, or delete any data at all. Still, many AI apps need to insert new rows or update existing records. Fixed database roles group insert, update, and delete rights together in the writer role. Because you cannot change fixed roles, you must manage custom table grants by hand.
Even with custom grants, database roles only check who logs in at the start. They do not inspect what individual statements do while queries run in flight. An agent with update rights can still overwrite columns with blank values across a table. Native roles also do not rewrite sensitive fields like emails or phone numbers. If a user asks for customer data, the query returns raw card numbers. Teams need a way to inspect each query and mask national IDs in results.
AI Data Exfiltration Prevention + SQL Injection Prevention: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
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
Can fixed database roles block deletes while allowing inserts?
No, the fixed data writer role allows adding, changing, and deleting data together. You cannot change the permissions assigned to fixed database roles in SQL Server. To allow inserts while blocking deletes, you must grant specific permissions on each table.
What happens if an AI app uses the database owner role?
A user in the owner role can run all setup and maintenance tasks. It can delete rows from any table and can drop the whole database. You should never use this role for an AI tool integration.
When should a team use a contained database user for an AI app?
A contained user works well when the app needs one or a few databases. It uses a password inside the database and does not need a master login. An admin must turn on the contained database setting on the server first.
Related guides
In this post