How to Check Database Encryption Status in SQL Server

977 views 11:58 0 Comments 3 April 2023


Data security is a critical aspect of database management, and encrypting sensitive data is crucial to safeguarding it from unauthorized access. In SQL Server, Transparent Data Encryption (TDE) provides real-time encryption and decryption of the entire database, ensuring the confidentiality of data at rest. In this blog post, we will explore how to check the database encryption status in SQL Server using T-SQL.

Understanding Transparent Data Encryption (TDE)

Transparent Data Encryption (TDE) is a feature in SQL Server that enables the encryption of an entire database, including data files, log files, and backups. TDE ensures that if someone gains access to the database files, the data remains encrypted and unreadable without the appropriate encryption keys.

Checking Database Encryption Status

To check the database encryption status in SQL Server, we can use the following steps:

  • Step 1: Connect to the SQL Server Instance: Using SQL Server Management Studio (SSMS) or any other preferred database management tool, establish a connection to the SQL Server instance.
  • Step 2: Execute the T-SQL Query: Open a new query window and execute the following T-SQL query:
    @@SERVERNAME AS 'Server Name', AS 'Database Name',
    CASE db.is_encrypted
        WHEN 0 THEN 'No Encryption'
        WHEN 1 THEN 'Unencrypted'
        WHEN 2 THEN 'Encryption in Progress'
        WHEN 3 THEN 'Encrypted'
        WHEN 4 THEN 'Key Change in Progress'
        WHEN 5 THEN 'Decryption in Progress'
        WHEN 6 THEN 'Protection Change in Progress'
        ELSE 'Unknown'
    END AS 'Is Encrypted',
    dm.encryption_state AS 'Encryption State',
    dm.percent_complete AS 'Encryption Progress',
    dm.key_algorithm AS 'Encryption Algorithm',
    dm.key_length AS 'Encryption Key Length'
    sys.databases db
LEFT JOIN sys.dm_database_encryption_keys dm
    ON db.database_id = dm.database_id;
  • Step 3: Analyze the Results: The executed query will return a result set with the following columns:
  1. ‘Server Name’: Name of the SQL Server instance.
  2. ‘Database Name’: Name of the database.
  3. ‘Is Encrypted’: Indicates the encryption status of the database, such as ‘No Encryption’, ‘Unencrypted’, ‘Encryption in Progress’, ‘Encrypted’, ‘Key Change in Progress’, ‘Decryption in Progress’, or ‘Protection Change in Progress’.
  4. ‘Encryption State’: Describes the encryption state of the database.
  5. ‘Encryption Progress’: Indicates the percentage of encryption or decryption process completed.
  6. ‘Encryption Algorithm’: Specifies the algorithm used for database encryption.
  7. ‘Encryption Key Length’: Indicates the length of the encryption key used for the database.

Review the result set to determine the encryption status of each database. The ‘Is Encrypted’ column provides clear information about the encryption status, making it easy to identify encrypted, unencrypted, or databases undergoing encryption-related changes.


Ensuring the security of data is of utmost importance in any organization. By checking the database encryption status in SQL Server, you can verify that your sensitive data is adequately protected. Using the provided T-SQL query, you can retrieve information about the encryption status of each database, including the encryption state, progress, algorithm, and key length.

Remember that Transparent Data Encryption (TDE) is just one approach to database encryption in SQL Server. Depending on your specific requirements, you may explore other encryption methods available in SQL Server to enhance data security further. Regularly monitoring and verifying the encryption status of databases is a best practice to maintain a robust and secure data environment.


Leave a Reply

Your email address will not be published. Required fields are marked *