Back to results for “Security”
SQL Server › SQL Server Security & Permissions

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

Beginner

Answer

A login is created at the server level and controls whether someone can connect to the SQL Server instance at all, while a database user exists within a specific database and is mapped to a login, controlling what that person is actually allowed to do once connected to that particular database.
CREATE LOGIN SalesUser WITH PASSWORD = 'SecurePassword123!';
CREATE USER SalesUser FOR LOGIN SalesUser;
Real-world example A company creates a login for a new employee allowing them to connect to the SQL Server instance, and then creates a corresponding database user in the sales database specifically, granting them access to just that one database.

Common follow-ups: Can a single login be mapped to users in multiple different databases?;What happens if a login exists but has no corresponding database user in a specific database?