views:

32

answers:

1

When I use Symmetric Encryption on a database and then back it up and then restore it to another SQL Server and use the same keys I can't decrypt the data.

Is there a way around this?

Using SQL Server 2008

Code:

GO 
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PASSWORD' 
GO 

CREATE CERTIFICATE PasswordFieldCertificate WITH SUBJECT = 'Password Fields';
GO 
CREATE SYMMETRIC KEY PasswordFieldSymmetricKey WITH ALGORITHM = TRIPLE_DES ENCRYPTION BY CERTIFICATE PasswordFieldCertificate; 
GO
A: 

Restore a database backup to a different machine then where it was backed up:

OPEN MASTER KEY DECRYPTION BY PASSWORD = 'Password' ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY CLOSE MASTER KEY

Note: If you don't do this, then you will not be able to decrypt the data.

RPS