Collections:
"CREATE USER" Statements - Creating a User in SQL Server
How to create a user to access a database using "CREATE USER" statements in SQL Server?
✍: FYIcenter.com
This is the second tutorial of a quick lesson on creating login and configure users for databases with Transact-SQL statements. Granting a user access to a database involves three steps. First, you create a login. The login lets the user connect to the SQL Server Database Engine. Then you configure the login as a user in the specified database. And finally, you grant that user permission to database objects. This lesson shows you these three steps, and shows you how to create a view and a stored procedure as the object. This tutorial assumes that you are running SQL Server Management Studio Express.
Mary now has access to this instance of SQL Server 2005, but does not have permission to access the databases. She does not even have access to her default database TestData until you authorize her as a database user.
To grant Mary access, switch to the TestData database, and then use the CREATE USER statement to map her login to a user named Mary.
To create a user in a database - Type and execute the following statements (replacing computer_name with the name of your computer) to grant Mary access to the TestData database.
USE [TestData]; GO CREATE USER [Mary] FOR LOGIN [computer_name\Mary]; GO
Now, Mary has access to both SQL Server 2005 and the TestData database.
⇒ "CREATE VIEW/PROCEDURE" Statements - Creating a View and a Stored Procedure in SQL Server
⇐ "CREATE LOGIN" Statements - Creating a Login in SQL Server
⇑ Getting Started with Transact-SQL Statements in SQL Server
2016-11-27, 1568🔥, 0💬
Popular Posts:
How To Change the Name of a Database User in SQL Server? If you want to change the name of an existi...
How To Convert Numeric Expression Data Types using the CONVERT() Function in SQL Server Transact-SQL...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time va...
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...