SQL Server Authentication Types

Published
Length
3 min read

Luis Felipe Dias

All posts

The main sql server authentication types rely on server logins or contained database users. These options verify who is logging in before the database checks their table permissions. A database user is the identity of a login inside a single database. SQL Server supports thirteen types of database users across different login methods. Teams pick between instance-level logins in the master database and contained users with passwords. That choice sets how people, apps, and AI agents log in each d

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.

The main sql server authentication types rely on server logins or contained database users. These options verify who is logging in before the database checks their table permissions.

A database user is the identity of a login inside a single database. SQL Server supports thirteen types of database users across different login methods. Teams pick between instance-level logins in the master database and contained users with passwords. That choice sets how people, apps, and AI agents log in each day.

How sql server authentication types work in practice

For people who need many databases on an instance, a login is standard. An admin creates this login inside the master database first. Then the admin maps that login to a user in each target database. When an engineer logs in, the server checks the master record first.

For access to one or a few databases, a contained user works well. A contained database user is a SQL user with a password. It does not tie back to a login in the master database. An admin must first turn on contained databases on the server and database.

Once a user logs in, fixed database roles control what they can do. Every role, including the public role, holds basic permission to connect. You cannot change the permissions built into fixed database roles. Instead, admins add users to specific roles to grant read or write power.

Members of the data reader role can read all data from user tables. They can also read from all user views in that database. Members of the data writer role can add, delete, or change table data. The database owner role can run all maintenance tasks and drop the database.

Security tradeoffs of static logins and fixed roles

Static logins and fixed roles solve basic gatekeeping, but gaps remain during sessions. A password tied to a SQL user can leak in scripts or chats. If an AI agent uses that login, it gets full role rights. The database cannot tell if a human or a script sent the query.

K8s API Server Authentication + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Fixed roles are also very broad inside a database. A data reader role lets a user read every user table and view. You cannot edit a fixed role to hide one sensitive column. If a table holds emails or card numbers, the reader gets them all.

Admins can use deny roles to block read or write actions altogether. A deny data reader role blocks reading from all user tables and views. A deny data writer role blocks adding, changing, or deleting any table data. Yet these roles still work at the whole database level, not per query.

Modern teams often add a proxy layer in front of the database. Engineers and AI agents log in with their own work identities instead. The proxy holds the database login and checks each query on the fly. Data masking can then rewrite emails, phone numbers, or national IDs in results.

Choosing the right setup for people and AI agents

Start by listing who needs database access and how many databases they touch. Use master logins when an admin or app works across the whole server. Use contained users when a service only needs one isolated database. Always pair those logins with the smallest fixed role that fits the job.

When AI agents or contractors run queries, static roles alone fall short. Adding query checks and data masking protects live data during active sessions. Masking rewrites card numbers and phone numbers before results leave the network. This keeps sensitive fields safe while letting teams read the tables they need.

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

How many types of database users exist in SQL Server?

SQL Server supports thirteen types of database users. The two most common patterns are users mapped to logins in master and contained users with passwords.

When should a team use a contained database user?

Use a contained database user when a person or app needs only one or a few databases. An admin must first turn on contained databases on the server and the database.

Can you change the permissions inside a fixed database role?

No, you cannot change the permissions assigned to fixed database roles. To limit what a reader gets in results, teams add data masking or table-level rules.

The query runs. The emails stay hidden.