How to: Create a Database Master Key

New: 17 July 2006

The database-level cryptographic features in SQL Server rely on a database master key. This key is not generated automatically when the database is created; it must be created by the system administrator. It is only necessary to create the master key once per database.

  1. In Query Editor, connect to the database by executing the following Transact-SQL command: USE <database name> ; GO.

  2. Choose a password for encrypting the copy of the master key that will be stored in the database.

  3. Execute the following Transact-SQL command: CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<password>' ; GO

You should immediately back up the new master key. For more information, see How to: Back Up a Database Master Key.

Community Additions