Creating a new SQL Server DB user is one of those tasks I do often enough that I get frustrated that I don’t remember how to do it, but not often enough to actually remember it. And for some reason, looking it up always seems to take a while. So, here I am, saving myself future headaches.
Step 1: Create SQL Server login by logging into the server as admin and running CREATE LOGIN [applogin] WITH PASSWORD=N'pa$$w0rd'
.
Step 2: Create new database user for login created in Step 1: USE appdb
CREATE USER applogin FOR LOGIN applogin
Step 3: Grant permissions to user on the specific database:EXEC sp_addrolemember 'db_owner', 'applogin'