Azure SQL Grant Select on Table
To run an azure sql grant select on table rule, you assign read rights to a user. This step lets a person or app read one table without touching the rest of the database. Teams often start by giving out broad read roles to save time. That choice exposes every table and view in the database to any person or agent with the key. Scoping read rights to single tables is a safer way to share data. How an azure sql grant select on table rule works Before you grant table rights, you need a database
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 azure sql grant select on table rule, you assign read rights to a user. This step lets a person or app read one table without touching the rest of the database.
Teams often start by giving out broad read roles to save time. That choice exposes every table and view in the database to any person or agent with the key. Scoping read rights to single tables is a safer way to share data.
How an azure sql grant select on table rule works
Before you grant table rights, you need a database user in place. A database user is the identity of a login when it connects to a database. Microsoft supports 13 types of database users for different access needs.
When people need access to many databases on an instance, teams use a login in master. That SQL user maps to the login at the server level. For access to one or a few databases, a contained database user is an option. A contained user is a SQL user with a password, not tied to a login in master. An admin must first enable contained databases on the server and the database.
Once the user exists, an admin can grant read rights on a specific table. All roles, including the default public role, already have the right to connect. The table grant then allows the user or AI agent to read rows from that single table. Queries against any other table in the database will fail right away.
Fixed database roles versus single table grants
Many admins use fixed database roles instead of table grants. For example, members of the datareader role can read all data from all user tables and views. Meanwhile, the datawriter role can add, delete, or change data in all user tables. At the top level, the owner role can run all setup and maintenance tasks. The owner role can even drop the database in SQL Server.
Fixed roles are fast to set up, but you cannot change their built-in permissions. If you put an engineer or AI tool in the datareader role, it sees every table. Some admins try to pair the datareader role with a deny role. Still, members of the denydatareader role cannot read any data from user tables and views. They also cannot read metadata about those objects.
Azure RBAC + Single Sign-On (SSO): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
This all-or-nothing design makes fixed roles a poor fit for least privilege. Granting read access table by table gives you much tighter control over what a user queries. You can also create a custom role, grant table rights to it, and add members.
Security gaps that remain during active sessions
Table grants solve the problem of which tables a user can query. Still, static database users and passwords still leave big gaps during a live session. Once a user has read rights on a table, all column and row comes back in full by default.
Customer tables often hold private data like emails, phone numbers, card numbers, or national IDs. A basic table grant returns all of that raw data to the person or AI agent. Also, static passwords for contained users or logins can leak in chat logs or scripts. If an attacker gets that password, they can dump the entire allowed table at any time.
Modern teams pair database roles with runtime controls to close these gaps. Short-lived session checks remove the need to hand out static database passwords to engineers. Data masking can also rewrite matched fields like emails or card numbers in query results. This approach keeps daily work fast while protecting sensitive rows in production.
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 login user and a contained database user?
A login user connects through an account stored in the master database. It works well when someone needs access to many databases on the same server. A contained user has a password inside the target database and needs no login in master.
Why should teams avoid the fixed datareader role for AI agents?
Members of the fixed datareader role can read all user tables and views in the database. You cannot change the permissions assigned to fixed database roles. Granting read rights on single tables stops an AI agent from reading unrelated tables.
Does a table read grant hide sensitive columns like emails or card numbers?
No, a standard table read grant lets the user read all column and row in that table by default. To protect private fields like emails, phone numbers, or card numbers, you need data masking or column rules.
Related guides
In this post