SQL Server Read Only Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up sql server read only permissions by adding a database user to a fixed reader role. This role lets users and AI agents read all user tables and views without changing any data. Teams rely on read roles to let engineers check live data and fix app bugs. AI agents and analytics tools also use these roles to run safe queries. Knowing how logins, users, and fixed roles interact helps you avoid common security gaps. How sql server read only permissions work in practice SQL Server splits

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 sql server read only permissions by adding a database user to a fixed reader role. This role lets users and AI agents read all user tables and views without changing any data.

Teams rely on read roles to let engineers check live data and fix app bugs. AI agents and analytics tools also use these roles to run safe queries. Knowing how logins, users, and fixed roles interact helps you avoid common security gaps.

How sql server read only permissions work in practice

SQL Server splits access into two layers: the server instance and the database itself. A database user is the identity of a login when it connects to a database. If a person needs to reach many databases on one instance, admins create a login in the master database first. Then they map that login to a user inside each target database.

For access to one or a few databases, a contained database user is another option. A contained user has a password inside the database and does not need a login in master. An admin must turn on contained databases on the server and database before using this option. In total, SQL Server supports thirteen types of database users to match different identity setups.

Once the user exists, admins grant read access through a fixed database role. The built-in reader role lets members read all data from all user tables and views. All database roles, including the default public role, include the basic permission to connect. You cannot change the permissions that belong to a fixed database role.

Sometimes admins also use deny roles to tighten access rules across a database. A deny writer role stops a user from adding, changing, or deleting data in any user table. A deny reader role blocks a user from reading data or metadata from user tables and views. Admins add users to these roles using standard role alteration statements.

Security tradeoffs of static roles and credentials

Fixed database roles are simple to set up, but they are very broad. Every member of the built-in reader role can query every user table and view in that database. If a table holds emails, phone numbers, card numbers, or national IDs, a read role returns them all. The database role alone does not filter out private columns during a query.

Read-Only Root Filesystem + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static login credentials create another risk for engineering teams and AI agents. When a team shares a read-only login, audit logs only show the shared account name. You cannot tell which engineer or automated script ran an expensive or risky query. Long-lived passwords also stay active until someone rotates them by hand.

To reduce these risks, teams pair database roles with query controls and data masking. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in query results. Tying every query to an individual identity also gives security teams a clear audit trail. This approach keeps daily debugging fast while keeping private records safe.

When to use custom roles instead of fixed roles

Fixed roles work well when a user needs to read the entire database schema. Still, many apps store public data and restricted billing tables in the same database. In those cases, the built-in reader role gives away too much access.

Database admins can create custom roles to limit which schemas or tables a user can read. A custom role lets you grant read access on specific views while blocking raw base tables. Combining scoped roles with dynamic field masking gives both people and AI agents safe, minimal access.

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

Can you change the permissions of a fixed database role in SQL Server?

No, you cannot change the permissions assigned to fixed database roles in SQL Server. If you need custom read rules for specific tables, you must create a user-defined database role instead.

What is the difference between a login user and a contained database user?

A standard SQL user maps to a server login stored in the master database for multi-database access. A contained database user logs in with a password stored inside the target database itself.

Does a read-only role hide sensitive columns like card numbers or emails?

No, the built-in reader role lets members read all data in every user table and view. To hide emails, phone numbers, card numbers, or national IDs, you need data masking that rewrites matched fields in results.

The query runs. The emails stay hidden.