How to map a user to a sql server database


Suppose a new database ‘dbNewDB’ is created on sql server database. Now to add an existing  user(existing sql server user) to this database with control,  following script can be use :

Let the existing user is ‘existingUser’

USE  dbNewDB
GO
CREATE USER existingUser FOR LOGIN existingUser WITH DEFAULT_SCHEMA=[dbo]
GO       
GRANT CONNECT,CONTROL to existingUser

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: