After creation of LOGIN at server-level in SQL server, we can create database user for that LOGIN.
Assume that we have LOGIN created with name TestLogin
. Below is the code snippet to create a database user for that LOGIN
-- Create User and map with particular login
/* CREATE USER UserName FOR LOGIN LoginName WITH DEFAULT_SCHEMA = [dbo] */
CREATE USER [TestUser] FOR LOGIN [TestLogin ] WITH DEFAULT_SCHEMA=[dbo]
NOTE: we can specify the default schema name at the time of user creation itself. The default schema is dbo