How to: Restore a Database Master Key
New: 17 July 2006
This topic describes how to restore a database master key from backups.
To restore a database master key
In SQL Server Management Studio, connect to the database to which you wish to restore the database master key.
Copy the backed-up key to a local NTFS directory. The directory should be protected with highly restrictive ACLs.
In Query Editor, execute the following Transact-SQL command:
RESTORE MASTER KEY FROM FILE = '<complete path and filename>' DECRYPTION BY PASSWORD = '<password1>' ENCRYPTION BY PASSWORD = '<password2>' ; GO
Where password1 is the password that was used to encrypt the key on the backup medium, and password2 is the password with which to encrypt a copy of the key in the database.
See Also
Tasks
How to: Back Up a Database Master Key
Other Resources
RESTORE MASTER KEY (Transact-SQL)