O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using T-SQL to Manage Users

CREATE USER, ALTER USER, and DROP USER are the T-SQL commands you use most often to manage database users. These commands are replacements for the system stored procedures used in prior versions. The system stored procedures, such as sp_adduser, sp_dropuser, sp_grantdbaccess, and sp_revokedbaccess, have been deprecated and will be removed in a future version. They are still available for use now, but you should avoid them when possible.

The following example demonstrates the use of the CREATE USER statement to create a new database user named Laura, with a default schema Sales:

CREATE USER Laura FOR LOGIN Laura    WITH DEFAULT_SCHEMA = Sales

You can use the ALTER USER statement to change ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required