USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘test’;
go
CREATE CERTIFICATE MyServerCert WITH SUBJECT = ‘My test DEK Certificate’;
go
USE testxml;
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_128
ENCRYPTION BY SERVER CERTIFICATE MyServerCert;
GO
ALTER DATABASE testxml
SET ENCRYPTION ON;
GO
backup certificate MyServerCert to file=’C:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\Backup\test_cert’;
Go
ALTER DATABASE testxml
SET ENCRYPTION OFF;
GO