Creation of Database User in SQL Server

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 207
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


USE DatabaseName
GO
-- 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]
GO



NOTE: we can specify the default schema name at the time of user creation itself. The default schema is dbo

Comments or Responses

Login to post response