Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Imports a service master key from a backup file.
Transact-SQL Syntax Conventions
RESTORE SERVICE MASTER KEY FROM FILE = 'path_to_file'
DECRYPTION BY PASSWORD = 'password' [FORCE]
When the service master key is restored, SQL Server decrypts all the keys and secrets that have been encrypted with the current service master key, and then encrypts them with the service master key loaded from the backup file.
If any one of the decryptions fails, the restore will fail. You can use the FORCE option to ignore errors, but this option will cause the loss of any data that cannot be decrypted.
Warning
The service master key is the root of the SQL Server encryption hierarchy. The service master key directly or indirectly secures all other keys in the tree. If a dependent key cannot be decrypted during a forced restore, data that is secured by that key will be lost.
Regenerating the encryption hierarchy is a resource-intensive operation. You should schedule this during a period of low demand.
Requires CONTROL SERVER permission on the server.
The following example restores the service master key from a backup file.
RESTORE SERVICE MASTER KEY
FROM FILE = 'c:\temp_backups\keys\service_master_key'
DECRYPTION BY PASSWORD = '3dH85Hhk003GHk2597gheij4';
GO
ALTER SERVICE MASTER KEY (Transact-SQL)
BACKUP SERVICE MASTER KEY (Transact-SQL)
Please sign in to use this experience.
Sign in