Hi there,
I am trying to recreate a database from a live backup file that was provided to us.
Before I perform the restore, the database requires a cert to be applied because it is encrypted.
So i run the following script which references the correct key and cert files:
------------------------------------------------------
USE master;
DROP CERTIFICATE NCSServerCert
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'my password'
GO
CREATE CERTIFICATE NCSServerCert
FROM FILE = 'E:\EncryptKey\NCSIS_Certificate.cer'
WITH PRIVATE KEY (FILE = 'E:\EncryptKey\Key.pvk',
DECRYPTION BY PASSWORD = 'my password');
GO
---------------------------------------------------------
When I run my script to apply the certificate, it fails saying:
Msg 15578, Level 16, State 1, Line 3
There is already a master key in the database. Please drop it before performing this statement.
Msg 15232, Level 16, State 1, Line 2
A certificate with name 'NCSServerCert' already exists or this certificate already has been added to the database.
So I tried dropping the cert before re-applying the script, but the message I get is as follows:
The certificate 'NCSServerCert' cannot be dropped because it is bound to one or more database encryption key.
At this point I am unsure as to how to proceed from here.
We need the live database recreated from this file so that we can do our comparison between UAT and live schemas
Any help would be appreciated,
Adam