SQL Server Table Read Only Access
You grant sql server table read only access by assigning select rights to a user or role. You can apply this permission to one table or use a fixed role for all tables. Teams often need to read production data to fix bugs or build reports. AI agents also need safe ways to query tables without changing records. Giving broad write rights creates big risks for your data. Setting up clear read rules keeps your database safe from bad updates. How sql server table read only access works in practice
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 grant sql server table read only access by assigning select rights to a user or role. You can apply this permission to one table or use a fixed role for all tables.
Teams often need to read production data to fix bugs or build reports. AI agents also need safe ways to query tables without changing records. Giving broad write rights creates big risks for your data. Setting up clear read rules keeps your database safe from bad updates.
How sql server table read only access works in practice
In SQL Server, a database user is the identity of a login inside a database. When someone needs to reach many databases on one server, admins create a login in master. Then they map that login to a user in each database.
For one or a few databases, a contained database user is another option. This user has a password and does not tie to a login in master. An admin must first turn on contained databases on the server and the database. SQL Server supports thirteen types of database users in total.
Once the user exists, admins can grant read rights in two main ways. The fast way uses the fixed database role for reading data. Members of this reader role can read all data from all user tables and views. You cannot change the permissions assigned to fixed database roles.
When a user or AI agent only needs one table, the reader role is too broad. Instead, admins create a custom role or grant select rights on that single table. They can also use a deny role to block reads or writes across all user tables. Members of the deny reader role cannot read any data from user tables or views.
Security tradeoffs of static roles and credentials
Native database roles control which tables a user can read or change. Still, static roles and passwords leave major gaps during an active session. Once a user logs in with a password, that key stays active until someone rotates it. Shared passwords make it hard to see which person ran a specific query.
Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Read rights on a table also expose all column and row inside that table. Customer tables often hold emails, phone numbers, card numbers, and national IDs. A basic read role returns all of these sensitive values in plain text. If an engineer or AI tool queries that table, the results include raw private data.
Managing table grants across dozens of databases takes a lot of manual work. Admins must track which users have custom grants and which ones sit in fixed roles. Over time, old accounts collect too many permissions across the server.
Controlling queries and sensitive data at the session layer
Modern teams pair database roles with session controls to close these gaps. Instead of handing out static database passwords, teams log in with their work identity. This setup ties every query to a real person or service account in the audit log.
Data masking adds another layer of safety for read queries. When a user runs a query, masking rewrites matched fields in results right away. Emails, phone numbers, and card numbers get masked before the data reaches the screen. Engineers can still check table logic and row counts without exposing raw private fields.
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 sits inline in the TDS protocol beside the database as a sidecar for your SQL Server. For every query an agent or human runs in production, hoop.dev decides whether to pass, mask, block, or escalate it for review.
With hoop.dev SQL Server controls, rules refuse banned statements before they run, hold risky queries for human review, and mask matched sensitive values in supported result columns in memory. 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
What is the difference between a fixed reader role and table grants?
The fixed reader role lets a user read all user tables and views in the database. Table grants let an admin limit read rights to one or more specific tables.
Can I change the permissions of a fixed database role in SQL Server?
No, you cannot change the permissions built into fixed database roles. If you need custom rules for specific tables, you must create a custom database role.
How do I stop a user from changing data while keeping read access?
Remove the user from any writer or owner roles in the database. You can also add the user to the deny writer role to block all data changes.
Related guides
In this post