---
title: "Create a Database Master Key | Microsoft Docs"
ms.custom: ""
ms.date: "03/14/2017"
ms.prod: "sql-non-specified"
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
ms.service: ""
ms.component: "security"
ms.reviewer: ""
ms.suite: "sql"
ms.technology:
- "database-engine"
ms.tgt_pltfrm: ""
ms.topic: "article"
helpviewer_keywords:
- "database master key [SQL Server], creating"
ms.assetid: 8cb24263-e97d-4e4d-9429-6cf494a4d5eb
caps.latest.revision: 16
author: "edmacauley"
ms.author: "edmaca"
manager: "craigg"
ms.workload: "On Demand"
---
# Create a Database Master Key
[!INCLUDE[appliesto-ss-asdb-asdw-pdw-md](../../../includes/appliesto-ss-asdb-asdw-pdw-md.md)]
This topic describes how to create a database master key in [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)] by using [!INCLUDE[tsql](../../../includes/tsql-md.md)].
**In This Topic**
- **Before you begin:**
[Security](#Security)
- [To create a database master key using Transact-SQL](#TsqlProcedure)
## Before You Begin
### Security
#### Permissions
Requires CONTROL permission on the database.
## Using Transact-SQL
#### To create a database master key
1. Choose a password for encrypting the copy of the master key that will be stored in the database.
2. In **Object Explorer**, connect to an instance of [!INCLUDE[ssDE](../../../includes/ssde-md.md)].
3. On the Standard bar, click **New Query**.
4. Copy and paste the following example into the query window and click **Execute**.
```
-- Creates a database master key for the "AdventureWorks2012" database.
-- The key is encrypted using the password "23987hxJ#KL95234nl0zBe."
USE AdventureWorks2012;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '23987hxJ#KL95234nl0zBe';
GO
```
For more information, see [CREATE MASTER KEY (Transact-SQL)](../../../t-sql/statements/create-master-key-transact-sql.md).