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 ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.