SQL Server Create User Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

To handle a sql server create user read only access request, map a login to a database user. Then add that user to the fixed data reader role so they can read all user tables. This setup lets people and tools run queries without changing any stored records. Teams use this pattern for reporting, debugging, and automated tasks. How sql server create user read only access works SQL Server splits identity into two layers across the server and the database. A login lives in the master database an

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 handle a sql server create user read only access request, map a login to a database user. Then add that user to the fixed data reader role so they can read all user tables.

This setup lets people and tools run queries without changing any stored records. Teams use this pattern for reporting, debugging, and automated tasks.

How sql server create user read only access works

SQL Server splits identity into two layers across the server and the database. A login lives in the master database and lets someone enter the server instance. A database user is the identity of that login inside one specific database. When someone needs to reach many databases on one instance, admins create a login first. Then they create a matching database user inside each target database. SQL Server supports thirteen types of database users for different identity needs.

Sometimes a person or AI agent only needs one or a few databases. In that case, a contained database user is another good option. A contained user has a password inside the database itself. It does not tie back to a login in the master database. An admin must turn on contained databases on the server and database first.

Once the user exists, you grant read rights through a fixed database role. Every database role, including the default public role, already has permission to connect. Adding a user to the data reader role lets them read all user tables. They can also read all user views in that database. You cannot change the permissions assigned to fixed database roles.

Security and operational tradeoffs of static read roles

Fixed roles are simple to set up, but they have real limits. The data reader role opens every user table and view in the database. It does not hide sensitive columns Inside those tables. Anyone with this role can query emails, phone numbers, card numbers, or national IDs.

To block changes, admins sometimes add the deny data writer role. Members of that role cannot add, change, or delete any table data. If you need to block all reads, the deny data reader role stops table and view queries. It also blocks metadata reads for those objects. By contrast, the database owner role can run all maintenance tasks and drop the database.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static database roles also leave gaps during an active session. Once a developer or AI agent logs in, the database trusts every read query. Static credentials stay valid until an admin rotates or removes them. Shared read logins make it hard to tie a query to one person. If a script pulls a full table of customer emails, the role allows it. Teams often add a proxy layer to mask fields and log each query.

Managing read access for engineers and AI agents

Modern teams run both human queries and automated AI agents against production data. Giving each tool a permanent login creates extra keys to track and rotate. If an agent shares a login with an engineer, audit logs get messy. You can see which database user ran a query, but not which person.

A better pattern keeps database roles strict while managing sessions outside the database. Short sessions reduce the risk of leaked passwords sitting in local files. Dynamic data masking can also rewrite matched fields like card numbers in query results. This keeps debugging fast while protecting sensitive columns from broad read roles.

Check SQL Server batches and results on the wire

SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between a SQL Server login and a database user?

A login authenticates you at the server level in the master database. A database user maps that login to one specific database and holds your roles there.

When should I use a contained database user for read access?

Use a contained user when someone needs access to only one or a few databases. The admin must enable contained databases on the server and target database first.

Does the fixed data reader role hide sensitive columns like emails?

No, the fixed data reader role lets members read all data in all user tables and views. You cannot change the permissions of a fixed role to hide specific columns.

The query runs. The emails stay hidden.