Published on

February 5, 2020

Fixing Database Encryption Issue in SQL Server

As a SQL Server consultant, I often come across various issues that require troubleshooting and problem-solving. Recently, I encountered a situation where a client was unable to add a database to an availability group due to an encryption error. In this blog post, I will share the steps I took to resolve this issue.

The error message my client received was: “This database is encrypted by database master key, you need to provide the valid password when adding it to the availability group.” Initially, my client was confused because the database did not have Transparent Data Encryption (TDE) enabled, and there was no other encryption used.

To investigate further, I used SQL Server Profiler to capture the queries being executed by the application. In the profiler, I found a query that was causing the issue:

SELECT
    c.create_date AS [CreateDate]
FROM
    sys.symmetric_keys AS c
WHERE
    (c.symmetric_key_id = 101)

When I executed the same query in SQL Server Management Studio (SSMS), I found a row for the database with the name “##MS_DatabaseMasterKey##”. This indicated that a database master key was created in the database, which was causing the encryption error.

To resolve this issue, I followed the below workaround/solution:

USE [DatabaseName]
GO
DROP MASTER KEY

After executing the above command, my client was able to successfully add the database to the availability group without any encryption-related errors.

It is important to note that before dropping the master key, you should ensure that the database does not have TDE enabled and there are no other encryption methods being used.

Fixing database encryption issues in SQL Server requires a thorough understanding of the underlying encryption mechanisms and the ability to troubleshoot effectively. By sharing this experience, I hope to help others who may encounter similar issues in their SQL Server environments.

Thank you for reading!

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.