How to drop Certificate and master key from the server.

 /*
  Follow below process to drop certificate and master key
 */
use master;
go
select
    database_name = d.name,
    dek.encryptor_type,
    cert_name = c.name
from sys.dm_database_encryption_keys dek
left join sys.certificates c
on dek.encryptor_thumbprint = c.thumbprint
inner join sys.databases d
on dek.database_id = d.database_id;
GO
/*
 First encryption off on the respective database
*/
USE master
go
ALTER DATABASE G
SET ENCRYPTION OFF
go
/*
drop the encryption key from the user database
*/
use G
GO
drop database encryption key
GO
/*
drop the certificate from master database.
*/
USE master
go
DROP CERTIFICATE MyServerCert1

/*
drop master key from master database
*/
DROP MASTER KEY

Comments

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period

Transparent Data Encryption(TDE) with Master Key and Certificate in SQL Server