Tuesday, December 29, 2015

Creating user without mentioning the login name



As a sysadmin, I create a login:
CREATE LOGIN BobSmith WITH PASSWORD = 'mypassword'
I now am in the Sales database and execute this:
CREATE USER BobSmith
What happens?

The user BobSmith is created and mapped to the login BobSmith
If a login name exists with the same name as a user, it is automatically mapped.

Source: SQL Server Central QoD().