This topic describes how to to protect a database by using transparent data encryption (TDE), and then move the database to another instance of SQL Server by using SQL Server Management Studio or Transact-SQL. TDE performs real-time I/O encryption and decryption of the data and log files. The encryption uses a database encryption key (DEK), which is stored in the database boot record for availability during recovery. The DEK is a symmetric key secured by using a certificate stored in the master database of the server or an asymmetric key protected by an EKM module.
Before You Begin
Limitations and Restrictions
When moving a TDE protected database, you must also move the certificate or asymmetric key that is used to open the DEK. The certificate or asymmetric key must be installed in the master database of the destination server, so that SQL Server can access the database files. For more information, see Transparent Data Encryption (TDE).
You must retain copies of both the certificate file and the private key file in order to recover the certificate. The password for the private key does not have to be the same as the database master key password.
SQL Server stores the files created here in C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA by default. Your file names and locations might be different.
Security
Permissions
Requires CONTROL DATABASE permission on the master database to create the database master key.
Requires CREATE CERTIFICATE permission on the master database to create the certificate that protects the DEK.
Requires CONTROL DATABASE permission on the encrypted database and VIEW DEFINITION permission on the certificate or asymmetric key that is used to encrypt the database encryption key.
To create a database protected by transparent data encryption
Using SQL Server Management Studio
Create a database master key and certificate in the master database. For more information, see Using Transact-SQL below.
Create a backup of the server certificate in the master database. For more information, see Using Transact-SQL below.
In Object Explorer, right-click the Databases folder and select New Database.
In the New Database dialog box, in the Database name box, enter the name of the new database.
In the Owner box, enter the name of the new database's owner. Alternately, click the ellipsis (…) to open the Select Database Owner dialog box. For more information on creating a new database.
In Object Explorer, click the plus sign to expand the Databases folder.
Right-click the database you created, point to Tasks, and select Manage Database Encryption.
The following options are available on the Manage Database Encryption dialog box.
Encryption Algorithm
Displays or sets the algorithm to use for database encryption. AES128 is the default algorithm. This field cannot be blank. For more information on encryption algorithms, see Choose an Encryption Algorithm.
Use server certificate
Sets the encryption to be secured by a certificate. Select one from the list. If you do not have the VIEW DEFINITION permission on server certificates, this list will be empty. If a certificate method of encryption is selected, this value cannot be empty. For more information about certificates, see SQL Server Certificates and Asymmetric Keys.
Use server asymmetric key
Sets the encryption to be secured by an asymmetric key. Only available asymmetric keys are displayed. Only an asymmetric key protected by an EKM module can encrypt a database using TDE.
Set Database Encryption On
Alters the database to turn on (checked) or turn off (unchecked) TDE.
When finished, click OK.
Using Transact-SQL
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute
by