Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize



Applies To: SQL Server 2014, SQL Server 2016 Preview

Creates a database master key.

Applies to: SQL Server (SQL Server 2008 through current version), SQL Database V12 (Preview in some regions), Azure SQL Data Warehouse Public Preview.

Topic link icon Transact-SQL Syntax Conventions


PASSWORD = 'password' 

Is the password that is used to encrypt the master key in the database. password must meet the Windows password policy requirements of the computer that is running the instance of SQL Server.

The database master key is a symmetric key used to protect the private keys of certificates and asymmetric keys that are present in the database. When it is created, the master key is encrypted by using the AES_256 algorithm and a user-supplied password. In SQL Server 2008 and SQL Server 2008 R2, the Triple DES algorithm is used. To enable the automatic decryption of the master key, a copy of the key is encrypted by using the service master key and stored in both the database and in master. Typically, the copy stored in master is silently updated whenever the master key is changed. This default can be changed by using the DROP ENCRYPTION BY SERVICE MASTER KEY option of ALTER MASTER KEY. A master key that is not encrypted by the service master key must be opened by using the OPEN MASTER KEY statement and a password.

The is_master_key_encrypted_by_server column of the sys.databases catalog view in master indicates whether the database master key is encrypted by the service master key.

Information about the database master key is visible in the sys.symmetric_keys catalog view.


You should back up the master key by using BACKUP MASTER KEY and store the backup in a secure, off-site location.

The service master key and database master keys are protected by using the AES-256 algorithm.

Requires CONTROL permission on the database.

The following example creates a database master key for the AdventureWorks2012 database. The key is encrypted using the password 23987hxJ#KL95234nl0zBe.

USE AdventureWorks2012;
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft