How to Configure Semantic Kernel SQL Server Prevent Delete
You set up semantic kernel sql server prevent delete by limiting database user rights. Give the agent login read rights or custom write roles that block deletes. Teams often start by giving AI plugins a shared admin account to move fast. Broad roles let a bad prompt wipe out rows or drop the whole database. How semantic kernel sql server prevent delete works with roles In SQL Server, a database user is the identity of a login. When the app connects to a database, it uses this database user id
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 semantic kernel sql server prevent delete by limiting database user rights. Give the agent login read rights or custom write roles that block deletes. Teams often start by giving AI plugins a shared admin account to move fast. Broad roles let a bad prompt wipe out rows or drop the whole database.
How semantic kernel sql server prevent delete works with roles
In SQL Server, a database user is the identity of a login. When the app connects to a database, it uses this database user identity. If an agent needs many databases on an instance, use a login in master. For one or a few databases, you can use a contained database user. This is a SQL user with a password, not tied to master. An admin must first turn on contained databases on the server and database.
After you make the user, you must set up its permissions. SQL Server includes fixed database roles with permissions that you cannot change. The db_owner role can run all setup tasks and even drop the database. Never give db_owner to an AI plugin or automated tool. The db_datawriter role can add, delete, or change data in all user tables. Because db_datawriter includes delete rights, it will not block delete statements on its own.
If your AI agent only needs to read data, use the db_datareader role. Members of db_datareader can read all data from all user tables and views. You can also add the user to the db_denydatawriter fixed role. Members of db_denydatawriter cannot add, change, or delete any data in user tables. If the agent must insert or update rows, skip the fixed writer role. Instead, grant insert and update rights on specific tables and deny delete rights.
Where native database roles fall short in live operations
Native SQL Server roles decide who logs in and what tables they touch. They do not inspect what individual statements do in flight during a session. If you grant insert and update rights, the agent still holds live keys. The app stores these database passwords in local settings to open the connection.
SQL Injection Prevention + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also apply the same rules to every query from that user. You cannot pause a risky update for human review before it runs. Also, the db_datareader role lets the agent read all user tables and views. If a table holds emails, phone numbers, or card numbers, the query returns them. Native roles do not rewrite matched fields in results to mask sensitive data.
Teams also struggle to link a specific prompt to a database query. The database only sees the shared app user identity in its logs. It does not know which end user or prompt triggered the SQL statement. When you manage dozens of agents, updating table permissions across instances takes hours.
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 change the permissions of the db_datawriter role to block deletes?
No, you cannot change the permissions assigned to fixed database roles in SQL Server. Since db_datawriter allows adds, changes, and deletes, use custom table permissions instead.
Does the db_denydatawriter role stop an agent from deleting rows?
Yes, members of db_denydatawriter cannot add, change, or delete data in user tables. Still, this role also blocks inserts and updates, so it only fits read-only agents.
Should I use a standard login or a contained user for my AI app?
Use a contained database user if the agent only needs one database. Use a SQL user tied to a login in master for many databases.
Related guides
In this post