Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create a User Account in Microsoft SQL Databse

Posted on 2012-12-21
5
Medium Priority
?
249 Views
Last Modified: 2013-01-01
Hi,
Can anyone explain how to creat A User Account in a SQL Database.
0
Comment
Question by:Computers4me
5 Comments
 
LVL 23

Expert Comment

by:Steve Wales
ID: 38714496
It's a two step process.

First you have to create a login to the instance.

That can be a SQL Server account (with a password) or you take take the Windows AD login and pass that through.

Then you create a user in the database connected to that login and grant appropriate privileges.

use master
go
create login [fred] from windows with default database=[master]
go
use demo
go
create user fred for login fred
go
grant select on table to fred

Open in new window


The user name and the login name do not have to be the same.  Make sure you grant object permissions to the user, not the login.

There are exceptions, for example you can make a login a system wide administrator for all databases on the instance.

From the documentation:

Creating a login: http://msdn.microsoft.com/en-us/library/aa337562.aspx
Creating a user: http://msdn.microsoft.com/en-us/library/ms173463.aspx
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38714509
you can also right click on the database, and use the graphic user interface
0
 

Author Comment

by:Computers4me
ID: 38714512
How would you Pass through an AD User account?
0
 
LVL 23

Expert Comment

by:Steve Wales
ID: 38714535
If my domain is MYDOMAIN and my account is sjwales it would be:

create login [MYDOMAIN\sjwales] from windows with default database=[master]

Open in new window


All of this can be done from the SSMS GUI as well as indicated by esskayb2d.

The username could then be anything, drop the domain from user if you want, for example.

create user sjwales for login [MYDOMAIN\sjwales]

Open in new window


and then assign appropriate permissions to sjwales as needed.
0
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 2000 total points
ID: 38715021
In security tab create login as like

Create login
In database security node create user as like

create user
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question