Skip to content

Commit b659dda

Browse files
authored
docs: Add encryption key decryption workflow and certificate rename guidance (#36539)
- Add decryption procedure to DROP COLUMN ENCRYPTION KEY article with step-by-step workflow - Document certificate renaming limitation in ALTER CERTIFICATE article with TDE workaround - Apply Microsoft Writing Style Guide compliance (active voice, contractions) - Update Related content sections and metadata
1 parent 96ba7c5 commit b659dda

2 files changed

Lines changed: 151 additions & 82 deletions

File tree

docs/t-sql/statements/alter-certificate-transact-sql.md

Lines changed: 105 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "ALTER CERTIFICATE (Transact-SQL)"
33
description: ALTER CERTIFICATE (Transact-SQL)
44
author: VanMSFT
55
ms.author: vanto
6-
ms.date: "04/22/2019"
6+
ms.date: "01/30/2026"
77
ms.service: sql
88
ms.subservice: t-sql
99
ms.topic: reference
@@ -52,9 +52,8 @@ ALTER CERTIFICATE certificate_name
5252
[ DECRYPTION BY PASSWORD = 'current_password' ]
5353
[ [ , ] ENCRYPTION BY PASSWORD = 'new_password' ]
5454
}
55-
```
56-
57-
55+
```
56+
5857
```syntaxsql
5958
-- Syntax for Parallel Data Warehouse
6059
@@ -65,57 +64,108 @@ ALTER CERTIFICATE certificate_name
6564
FILE = '<path_to_private_key>',
6665
DECRYPTION BY PASSWORD = '<key password>' )
6766
}
68-
```
67+
```
6968

7069
## Arguments
71-
*certificate_name*
72-
Is the unique name by which the certificate is known in the database.
70+
71+
*certificate_name*
72+
The unique name by which the certificate is known in the database.
7373

7474
REMOVE PRIVATE KEY
75-
Specifies that the private key should no longer be maintained inside the database.
75+
Specifies that the private key will no longer be maintained inside the database.
7676

7777
WITH PRIVATE KEY
7878
Specifies that the private key of the certificate is loaded into SQL Server.
7979

80-
FILE ='*path_to_private_key*'
81-
Specifies the complete path, including file name, to the private key. This parameter can be a local path or a UNC path to a network location. This file will be accessed within the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account. When you use this option, make sure the service account has access to the specified file.
82-
83-
If only a file name is specified, the file is saved in the default user data folder for the instance. This folder might (or might not) be the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder. For SQL Server Express LocalDB, the default user data folder for the instance is the path specified by the `%USERPROFILE%` environment variable for the account that created the instance.
84-
85-
BINARY ='*private_key_bits*'
80+
FILE ='*path_to_private_key*'
81+
Specifies the complete path, including file name, to the private key. This parameter can be a local path or a UNC path to a network location. The file is accessed within the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account. When you use this option, make sure the service account has access to the specified file.
82+
83+
If you specify only a file name, the file is saved in the default user data folder for the instance. This folder might or might not be the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder. For SQL Server Express LocalDB, the default user data folder for the instance is the path specified by the `%USERPROFILE%` environment variable for the account that created the instance.
84+
85+
BINARY ='*private_key_bits*'
8686
**Applies to**: [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] and later.
8787

88-
Private key bits specified as binary constant. These bits can be in encrypted form. If encrypted, the user must provide a decryption password. Password policy checks are not performed on this password. The private key bits should be in a PVK file format.
89-
90-
DECRYPTION BY PASSWORD ='*current_password*'
91-
Specifies the password that is required to decrypt the private key.
92-
93-
ENCRYPTION BY PASSWORD ='*new_password*'
94-
Specifies the password used to encrypt the private key of the certificate in the database. *new_password* must meet the Windows password policy requirements of the computer that is running the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. For more information, see [Password Policy](../../relational-databases/security/password-policy.md).
95-
96-
ACTIVE FOR BEGIN_DIALOG **=** { ON | OFF }
97-
Makes the certificate available to the initiator of a [!INCLUDE[ssSB](../../includes/sssb-md.md)] dialog conversation.
98-
99-
## Remarks
100-
The private key must correspond to the public key specified by *certificate_name*.
101-
102-
The DECRYPTION BY PASSWORD clause can be omitted if the password in the file is protected with a null password.
103-
104-
When the private key of a certificate that already exists in the database is imported, the private key will be automatically protected by the database master key. To protect the private key with a password, use the ENCRYPTION BY PASSWORD clause.
105-
106-
The REMOVE PRIVATE KEY option will delete the private key of the certificate from the database. You can remove the private key when the certificate will be used to verify signatures or in [!INCLUDE[ssSB](../../includes/sssb-md.md)] scenarios that do not require a private key. Do not remove the private key of a certificate that protects a symmetric key. The private key will need to be restored in order to sign any additional modules or strings that should be verified with the certificate, or to decrypt a value that has been encrypted with the certificate.
107-
108-
You do not have to specify a decryption password when the private key is encrypted by using the database master key.
109-
110-
To change the password used for encrypting the private key, do not specify either the FILE or BINARY clauses.
88+
Private key bits specified as binary constant. These bits can be in encrypted form. If encrypted, you must provide a decryption password. SQL Server doesn't perform password policy checks on this password. The private key bits should be in a PVK file format.
11189

90+
DECRYPTION BY PASSWORD ='*current_password*'
91+
Specifies the password that is required to decrypt the private key.
92+
93+
ENCRYPTION BY PASSWORD ='*new_password*'
94+
Specifies the password used to encrypt the private key of the certificate in the database. *new_password* must meet the Windows password policy requirements of the computer that is running the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. For more information, see [Password Policy](../../relational-databases/security/password-policy.md).
95+
96+
ACTIVE FOR BEGIN_DIALOG **=** { ON | OFF }
97+
Makes the certificate available to the initiator of a [!INCLUDE[ssSB](../../includes/sssb-md.md)] dialog conversation.
98+
99+
## Remarks
100+
101+
The private key must correspond to the public key specified by *certificate_name*.
102+
103+
You can omit the DECRYPTION BY PASSWORD clause if the password in the file is protected with a null password.
104+
105+
When you import the private key of a certificate that already exists in the database, the private key is automatically protected by the database master key. To protect the private key with a password, use the ENCRYPTION BY PASSWORD clause.
106+
107+
The REMOVE PRIVATE KEY option deletes the private key of the certificate from the database. You can remove the private key when you use the certificate to verify signatures or in [!INCLUDE[ssSB](../../includes/sssb-md.md)] scenarios that don't require a private key. Don't remove the private key of a certificate that protects a symmetric key. You need to restore the private key to sign any additional modules or strings that should be verified with the certificate, or to decrypt a value that was encrypted with the certificate.
108+
109+
You don't have to specify a decryption password when the private key is encrypted by using the database master key.
110+
111+
To change the password used for encrypting the private key, don't specify either the FILE or BINARY clauses.
112+
112113
> [!IMPORTANT]
113-
> Always make an archival copy of a private key before removing it from a database. For more information, see [BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md) and [CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md).
114-
115-
The WITH PRIVATE KEY option is not available in a contained database.
116-
117-
## Permissions
118-
Requires ALTER permission on the certificate.
114+
> Always make an archival copy of a private key before removing it from a database. For more information, see [BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md) and [CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md).
115+
116+
The WITH PRIVATE KEY option isn't available in a contained database.
117+
118+
## Limitations
119+
120+
Certificate names can't be changed after creation. ALTER CERTIFICATE doesn't support renaming certificates. If you need to use a different certificate name, you must create a new certificate and migrate dependencies.
121+
122+
### Workaround for TDE certificates
123+
124+
If you need to replace a Transparent Data Encryption (TDE) certificate with a different name:
125+
126+
1. **Back up the current certificate and private key**:
127+
128+
```sql
129+
BACKUP CERTIFICATE OldTDECert
130+
TO FILE = 'C:\Backup\OldTDECert.cer'
131+
WITH PRIVATE KEY (
132+
FILE = 'C:\Backup\OldTDECert.pvk',
133+
ENCRYPTION BY PASSWORD = '<password>'
134+
);
135+
```
136+
137+
1. **Create the new certificate with the correct name**:
138+
139+
```sql
140+
CREATE CERTIFICATE NewTDECert
141+
WITH SUBJECT = 'TDE Certificate - Correct Name';
142+
```
143+
144+
1. **For each TDE-encrypted database, change the encryption key**:
145+
146+
```sql
147+
USE EncryptedDB;
148+
GO
149+
150+
ALTER DATABASE ENCRYPTION KEY
151+
ENCRYPTION BY SERVER CERTIFICATE NewTDECert;
152+
```
153+
154+
1. **After all databases are migrated, drop the old certificate**:
155+
156+
```sql
157+
USE master;
158+
GO
159+
160+
DROP CERTIFICATE OldTDECert;
161+
```
162+
163+
> [!IMPORTANT]
164+
> Always back up certificates and private keys before making TDE changes. Store backups in a secure location separate from the database server.
165+
166+
## Permissions
167+
168+
Requires ALTER permission on the certificate.
119169

120170
## Examples
121171

@@ -152,16 +202,15 @@ ALTER CERTIFICATE Shipping15
152202
WITH PRIVATE KEY (DECRYPTION BY PASSWORD = '95hk000eEnvjkjy#F%');
153203
GO
154204
```
155-
156-
## See Also
157-
[CREATE CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/create-certificate-transact-sql.md)
158-
[DROP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/drop-certificate-transact-sql.md)
159-
[BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md)
160-
[Encryption Hierarchy](../../relational-databases/security/encryption/encryption-hierarchy.md)
161-
[EVENTDATA &#40;Transact-SQL&#41;](../../t-sql/functions/eventdata-transact-sql.md)
162-
[CERTENCODED &#40;Transact-SQL&#41;](../../t-sql/functions/certencoded-transact-sql.md)
163-
[CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md)
164-
[CERT_ID &#40;Transact-SQL&#41;](../../t-sql/functions/cert-id-transact-sql.md)
165-
[CERTPROPERTY &#40;Transact-SQL&#41;](../../t-sql/functions/certproperty-transact-sql.md)
166-
167-
205+
206+
## Related content
207+
208+
- [CREATE CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/create-certificate-transact-sql.md)
209+
- [DROP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/drop-certificate-transact-sql.md)
210+
- [BACKUP CERTIFICATE &#40;Transact-SQL&#41;](../../t-sql/statements/backup-certificate-transact-sql.md)
211+
- [Encryption Hierarchy](../../relational-databases/security/encryption/encryption-hierarchy.md)
212+
- [EVENTDATA &#40;Transact-SQL&#41;](../../t-sql/functions/eventdata-transact-sql.md)
213+
- [CERTENCODED &#40;Transact-SQL&#41;](../../t-sql/functions/certencoded-transact-sql.md)
214+
- [CERTPRIVATEKEY &#40;Transact-SQL&#41;](../../t-sql/functions/certprivatekey-transact-sql.md)
215+
- [CERT_ID &#40;Transact-SQL&#41;](../../t-sql/functions/cert-id-transact-sql.md)
216+
- [CERTPROPERTY &#40;Transact-SQL&#41;](../../t-sql/functions/certproperty-transact-sql.md)

docs/t-sql/statements/drop-column-encryption-key-transact-sql.md

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "DROP COLUMN ENCRYPTION KEY (Transact-SQL)"
33
description: DROP COLUMN ENCRYPTION KEY (Transact-SQL)
44
author: jaszymas
55
ms.author: jaszymas
6-
ms.date: "10/15/2019"
6+
ms.date: "01/30/2026"
77
ms.service: sql
88
ms.subservice: t-sql
99
ms.topic: reference
@@ -30,35 +30,55 @@ dev_langs:
3030

3131
```syntaxsql
3232
DROP COLUMN ENCRYPTION KEY key_name [;]
33-
```
33+
```
3434

3535
## Arguments
36-
*key_name*
37-
Is the name by which the column encryption key to be dropped from the database.
36+
37+
*key_name*
38+
The name of the column encryption key to drop from the database.
3839

3940
## Remarks
40-
A column encryption key cannot be dropped if it is used to encrypt any column in the database. All columns using the column encryption key must first be dropped.
41-
42-
## Permissions
43-
Requires **ALTER ANY COLUMN ENCRYPTION KEY** permission on the database.
44-
45-
## Examples
46-
47-
### A. Dropping a column encryption key
48-
The following example drops a column encryption key called `MyCEK`.
49-
41+
42+
A column encryption key can't be dropped if it's used to encrypt any column in the database. All columns using the column encryption key must first be decrypted or dropped.
43+
44+
To remove encryption from a column:
45+
46+
1. **Decrypt the column** - Use `ALTER TABLE` to modify the encrypted column, removing the encryption specification:
47+
48+
```sql
49+
ALTER TABLE dbo.Employees
50+
ALTER COLUMN SSN NVARCHAR(11);
51+
```
52+
53+
2. **Drop the column encryption key** - After all columns using the key are decrypted, you can drop the key:
54+
55+
```sql
56+
DROP COLUMN ENCRYPTION KEY MyCEK;
57+
```
58+
59+
Alternatively, if you no longer need the column data, you can drop the column entirely using `ALTER TABLE DROP COLUMN` before dropping the encryption key.
60+
61+
## Permissions
62+
63+
Requires **ALTER ANY COLUMN ENCRYPTION KEY** permission on the database.
64+
65+
## Examples
66+
67+
### A. Dropping a column encryption key
68+
69+
The following example drops a column encryption key called `MyCEK`.
70+
5071
```sql
5172
DROP COLUMN ENCRYPTION KEY MyCEK;
5273
GO
53-
```
54-
55-
## See Also
56-
[CREATE COLUMN ENCRYPTION KEY &#40;Transact-SQL&#41;](../../t-sql/statements/create-column-encryption-key-transact-sql.md)
57-
[ALTER COLUMN ENCRYPTION KEY &#40;Transact-SQL&#41;](../../t-sql/statements/alter-column-encryption-key-transact-sql.md)
58-
[CREATE COLUMN MASTER KEY &#40;Transact-SQL&#41;](../../t-sql/statements/create-column-master-key-transact-sql.md)
59-
[Always Encrypted](../../relational-databases/security/encryption/always-encrypted-database-engine.md)
60-
[Always Encrypted with secure enclaves](../../relational-databases/security/encryption/always-encrypted-enclaves.md)
61-
[Overview of Key Management for Always Encrypted](../../relational-databases/security/encryption/overview-of-key-management-for-always-encrypted.md)
62-
[Manage keys for Always Encrypted with secure enclaves](../../relational-databases/security/encryption/always-encrypted-enclaves-manage-keys.md)
63-
64-
74+
```
75+
76+
## Related content
77+
78+
- [CREATE COLUMN ENCRYPTION KEY &#40;Transact-SQL&#41;](../../t-sql/statements/create-column-encryption-key-transact-sql.md)
79+
- [ALTER COLUMN ENCRYPTION KEY &#40;Transact-SQL&#41;](../../t-sql/statements/alter-column-encryption-key-transact-sql.md)
80+
- [CREATE COLUMN MASTER KEY &#40;Transact-SQL&#41;](../../t-sql/statements/create-column-master-key-transact-sql.md)
81+
- [Always Encrypted](../../relational-databases/security/encryption/always-encrypted-database-engine.md)
82+
- [Always Encrypted with secure enclaves](../../relational-databases/security/encryption/always-encrypted-enclaves.md)
83+
- [Overview of Key Management for Always Encrypted](../../relational-databases/security/encryption/overview-of-key-management-for-always-encrypted.md)
84+
- [Manage keys for Always Encrypted with secure enclaves](../../relational-databases/security/encryption/always-encrypted-enclaves-manage-keys.md)

0 commit comments

Comments
 (0)