Ms SQL Server Create Read Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

To run an ms sql server create read only user workflow, you pair an identity with a fixed read role. You create a database user and assign it to the built-in data reader role. This setup lets people and AI agents query data without changing any rows. It forms the basic building block for safe database checks and daily reports. Teams rely on this pattern to protect production records from bad writes. How the ms sql server create read only user process works SQL Server splits access into two l

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 run an ms sql server create read only user workflow, you pair an identity with a fixed read role. You create a database user and assign it to the built-in data reader role.

This setup lets people and AI agents query data without changing any rows. It forms the basic building block for safe database checks and daily reports. Teams rely on this pattern to protect production records from bad writes.

How the ms sql server create read only user process works

SQL Server splits access into two layers: the server instance and the database. A database user is the identity of a login inside a target database. When someone needs many databases on one instance, admins create a server login first. That login sits in the master database and maps to a local user.

Sometimes a person or AI agent only needs one or a few databases. In that case, a contained database user is a good option. This user has a password inside the target database and skips the master login. An admin must enable contained databases on the server and the database first. Across the platform, SQL Server supports thirteen types of database users.

Once the user exists, you must grant read permissions. All database roles, including the default public role, already have basic connect rights. To allow reads, admins add the user as a member of the fixed data reader role. You cannot change the permissions assigned to fixed database roles.

Members of the data reader role can read all data from all user tables. They can also read from all views in that database. If you want to block writes for sure, you can add the deny data writer role. That role stops the user from adding, changing, or deleting any table data.

Security and operational tradeoffs of static read roles

Fixed read roles work well for broad reporting and simple app queries. They stop accidental deletes and keep people from dropping tables like a full owner could. Still, static database users and fixed roles leave big gaps during an active session.

Read-Only Root Filesystem + User Provisioning (SCIM): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

First, the fixed data reader role grants read rights to every single user table. It does not separate safe lookup tables from tables with private customer records. Anyone with that role can query emails, phone numbers, card numbers, or national IDs. If an AI agent uses that login, it pulls raw sensitive values into its prompt.

Second, static passwords create work for your security team. Engineers often share one read-only login across scripts, notebooks, and local database tools. When a password leaks or a person leaves, rotating that shared key breaks running jobs. You also lose track of which human ran a specific slow query.

Third, database roles do not inspect queries in flight. A read-only user cannot change data, but they can still dump a full customer table. They can also run heavy joins that lock up CPU and slow down production apps. To fix this, teams put a query layer in front of the database. That layer ties each query to an individual user, logs every command, and masks sensitive columns.

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 sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.

With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.

Frequently asked questions

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

A login lives in the master database and lets you enter the server instance. A database user is the identity mapped to that login inside one specific database. You can also use a contained database user with its own password for single databases.

Does the fixed data reader role hide sensitive columns?

No, members of the fixed data reader role can read all user tables and views. The role does not filter out emails, phone numbers, card numbers, or national IDs. To protect those values, you need column permissions or a tool that rewrites matched fields in results.

How do you block a user from reading or writing data?

SQL Server includes fixed deny roles for both reading and writing data. The deny data reader role blocks a user from reading any user tables, views, or metadata. The deny data writer role stops a user from adding, changing, or deleting table rows.

The query runs. The emails stay hidden.