C. USE Customers;
ALTER USER User1 WITH LOGIN = User1;
D. USE Customers;
ALTER LOGIN User1 WITH DEFAULT_DATABASE = Customers;
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
___________________________________________________________
From MSDN: http://msdn.microsoft.com/en-us/library/ms176060.aspx
ALTER USER : Renames a database user or changes its default schema.
ALTER USER userName
WITH <set_item> [ ,...n ]
<set_item> ::=
NAME = newUserName | DEFAULT_SCHEMA = schemaName | LOGIN = loginName |
PASSWORD = 'password' [ OLD_PASSWORD = 'oldpassword' ]
Arguments:
userName
Specifies the name by which the user is identified inside this database.
LOGIN = loginName
Re-maps a user to another login by changing the user’s Security Identifier (SID) to match the login’s SID.
NAME = newUserName
Specifies the new name for this user. newUserName must not already occur in the current database.
DEFAULT_SCHEMA = schemaName
Specifies the first schema that will be searched by the server when it resolves the names of objects for this
user. Renames a database user or changes its default schema.
PASSWORD = 'password'
Specifies the password for the user that is being changed. Passwords are case-sensitive. Note: This
option is available only for contained users. See Contained Databases and sp_migrate_user_to_contained
(Transact-SQL) for more information.
OLD_PASSWORD ='oldpassword'
The current user password that will be replaced by 'password'. Passwords are case-sensitive.
OLD_PASSWORD is required to change a password, unless you have ALTER ANY USER permission.
Requiring OLD_PASSWORD prevents users with IMPERSONATION permission from changing the
password. Note: This option is available only for contained users.
___________________________________________________________
Remarks:
If DEFAULT_SCHEMA is left undefined, the user will have dbo as its default schema.
DEFAULT_SCHEMA can be set to a schema that does not currently occur in the database. Therefore, you
can assign a DEFAULT_SCHEMA to a user before that schema is created. DEFAULT_SCHEMA cannot
be specified for a user who is mapped to a Windows group, a certificate, or an asymmetric key.
Important:
The value of DEFAULT_SCHEMA is ignored if the user is a member of the sysadmin fixed server role. All
members of the sysadmin fixed server role have a default schema of dbo.
You can change the name of a user who is mapped to a Windows login or group only when the SID of the
new user name matches the SID that is recorded in the database. This check helps prevent spoofing of
Windows logins in the database.
The WITH LOGIN clause enables the remapping of a user to a different login. Users without a login, users
mapped to a certificate, or users mapped to an asymmetric key cannot be re-mapped with this clause.
Only SQL users and Windows users (or groups) can be remapped. The WITH LOGIN clause cannot be
used to change the type of user, such as changing a Windows account to a SQL Server login.
The name of the user will be automatically renamed to the login name if the following conditions are true.
The user is a Windows user.
The name is a Windows name (contains a backslash).
No new name was specified.
The current name differs from the login name.
Otherwise, the user will not be renamed unless the caller additionally invokes the NAME clause.
QUESTION 17
Note: This question is part of a series of questions that use the same or similar answer choices.