ALTER ASYMMETRIC KEY (Transact-SQL)
Changes the properties of an asymmetric key.
ALTER ASYMMETRIC KEY Asym_Key_Name <alter_option> <alter_option> ::= <password_change_option> | REMOVE PRIVATE KEY <password_change_option> ::= WITH PRIVATE KEY ( <password_option> [ , <password_option> ] )<password_option> ::= ENCRYPTION BY PASSWORD ='strongPassword' | DECRYPTION BY PASSWORD ='oldPassword'
If there is no database master key the ENCRYPTION BY PASSWORD option is required, and the operation will fail if no password is supplied. For information about how to create a database master key, see CREATE MASTER KEY (Transact-SQL).
You can use ALTER ASYMMETRIC KEY to change the protection of the private key by specifying PRIVATE KEY options as shown in the following table.
Change protection from
ENCRYPTION BY PASSWORD
DECRYPTION BY PASSWORD
Old password to new password
Password to master key
Master key to password
The database master key must be opened before it can be used to protect a private key. For more information, see OPEN MASTER KEY (Transact-SQL).
To change the ownership of an asymmetric key, use ALTER AUTHORIZATION.
A. Changing the password of the private key
The following example changes the password used to protect the private key of asymmetric key PacificSales09. The new password will be <enterStrongPasswordHere>.
ALTER ASYMMETRIC KEY PacificSales09 WITH PRIVATE KEY ( DECRYPTION BY PASSWORD = '<oldPassword>', ENCRYPTION BY PASSWORD = '<enterStrongPasswordHere>'); GO
B. Removing the private key from an asymmetric key
The following example removes the private key from PacificSales19, leaving only the public key.
ALTER ASYMMETRIC KEY PacificSales19 REMOVE PRIVATE KEY; GO
C. Removing password protection from a private key
The following example removes the password protection from a private key and protects it with the database master key.
OPEN MASTER KEY; ALTER ASYMMETRIC KEY PacificSales09 WITH PRIVATE KEY ( DECRYPTION BY PASSWORD = '<enterStrongPasswordHere>' ); GO