Database Encryption
I'm a newbie to SQL and I inherited a 2008 R2 Sql server with about 20 different databases on it.  I've noticed that more than half of the databases are encrypted and I was looking to encrypt the rest but for some reason I am unable to do so.  I'm assuming I already have a master key created but when I go to Options of the DB and change Encryption Enabled from False to True I get and error, "Cannot change database encryption state because no database encryption key is set."  Do you know how I could use my existing key to encrypt the databases or would I have to create a separate key fo
July 15th, 2015 5:01pm

no, you need to set the database encryption key and then enable the encryption on the database...try this demo on test box and understand

so, you need to find your certificate - select * from sys.certificates and use that (replace myserverCert in the code below)

--assume that I already have a master key and certificate - myServerCert. refer msdn example

https://msdn.microsoft.com/en-us/library/Bb934049.aspx?f=255&MSPPError=-2147217396

create database test2 go USE test2 GO CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_128 ENCRYPTION BY SERVER CERTIFICATE MyServerCert; GO ALTER DATABASE test2 SET ENCRYPTION ON; GO

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 6:03pm

The following example illustrates encrypting and decrypting the AdventureWorks2012 database using a certificate installed on the server named MyServerCert.

USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<UseStrongPasswordHere>';
go
CREATE CERTIFICATE MyServerCert WITH SUBJECT = 'My DEK Certificate';
go
USE AdventureWorks2012;
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_128
ENCRYPTION BY SERVER CERTIFICATE MyServerCert;
GO
ALTER DATABASE AdventureWorks2012
SET ENCRYPTION ON;
GO

  • Proposed as answer by Vero4ka Friday, July 17, 2015 11:36 AM
July 15th, 2015 7:03pm

I'm going to have to give this a try.

Would I have to run this on every database on my sql instance?

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:05pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics