Reputation: 23
Can anyone explain to me how to use the following Syntax:
-- Syntax for Azure SQL Database
ALTER USER userName
WITH <set_item> [ ,...n ]
<set_item> ::=
NAME = newUserName
| DEFAULT_SCHEMA = schemaName
| LOGIN = loginName
| ALLOW_ENCRYPTED_VALUE_MODIFICATIONS = [ ON | OFF ]
[;]
-- Azure SQL Database Update Syntax
ALTER USER userName
WITH <set_item> [ ,...n ]
[;]
<set_item> ::=
NAME = newUserName
| DEFAULT_SCHEMA = { schemaName | NULL }
| LOGIN = loginName
| PASSWORD = 'password' [ OLD_PASSWORD = 'oldpassword' ]
| ALLOW_ENCRYPTED_VALUE_MODIFICATIONS = [ ON | OFF ]
-- SQL Database syntax when connected to a federation member
ALTER USER userName
WITH <set_item> [ ,… n ]
[;]
I got it from this link https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-user-transact-sql
Thanks
Upvotes: 2
Views: 6611
Reputation: 15618
The most important use I have found for the ALTER USER is that it helps you map a database user to a server login. It allows to resolve mapping issues between database users and server logins
ALTER USER DBuser TO UserLogin
You can also use it to change the default schema of a database user
ALTER USER [DBUser] WITH DEFAULT_SCHEMA = [NewSch]
Finally, you can use it to change password of a SQL Azure contained database user. Contained users do not have a related server login.
ALTER USER DBUser WITH PASSWORD = '{your new password}'
Hope this helps.
Upvotes: 3