Encryption Layers and Column-Level Encryption
This lesson places TLS, TDE and column encryption in context and explains how server-side column-level encryption works.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish between encryption in transit, TDE and column encryption.
- Describe the key hierarchy of column-level encryption.
- Explain who can decrypt data protected by keys stored in the database.
Layers of encryption
Encryption in transit uses TLS between clients and the database; Azure SQL Database requires encrypted connections, and clients should validate the server certificate (Encrypt=True or Strict, without TrustServerCertificate). Encryption at rest with transparent data encryption (TDE) encrypts data files, log files and backups with a database encryption key; it is on by default in Azure SQL Database and SQL database in Fabric, with a service-managed key or a customer-managed key in Azure Key Vault. TDE protects against stolen files and backups, but anyone who can query the database sees plaintext.
Protecting individual values from people who can query the database needs column encryption: server-side column-level encryption or client-side Always Encrypted. The difference is where the keys are and who can therefore decrypt.
The following diagram shows the layer each encryption method protects.

Which layer protects it?
Server-side column-level encryption
Column-level encryption uses T-SQL functions. A symmetric key (for example AES_256) is protected by a certificate, which is protected by the database master key. Code opens the key, calls ENCRYPTBYKEY on write and DECRYPTBYKEY on read, and closes the key. Encrypted values are stored as varbinary, so the column cannot be indexed for searching by value; a separate hashed column (for example HASHBYTES with a salt) supports equality lookups.
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<strong password>';
CREATE CERTIFICATE PayrollCert WITH SUBJECT = 'Payroll column key protector';
CREATE SYMMETRIC KEY PayrollKey WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE PayrollCert;
OPEN SYMMETRIC KEY PayrollKey DECRYPTION BY CERTIFICATE PayrollCert;
UPDATE HR.Employee SET SalaryEnc = ENCRYPTBYKEY(KEY_GUID('PayrollKey'), CONVERT(varbinary(16), Salary));
SELECT EmployeeID, CONVERT(decimal(12,2), CONVERT(varbinary(16), DECRYPTBYKEY(SalaryEnc))) AS Salary
FROM HR.Employee;
CLOSE SYMMETRIC KEY PayrollKey;Because the server performs encryption with keys stored in the database, any principal with permission to open the key, such as a database owner or a sysadmin, can decrypt the data. Column-level encryption therefore protects values from users who can read the table but not open the key, not from administrators.
Setting up column-level encryption
Choosing an encryption approach
The following comparison shows which feature addresses which threat.
Which encryption?
What does TDE protect?
A compliance auditor asks whether TDE in Azure SQL Database prevents the database administrator from reading customer passport numbers. The policy requires that only the passport office application can read them in plaintext. What should the developer recommend?
TDE does not meet the requirement because it decrypts data transparently for anyone who can query it. Encrypt the passport column with Always Encrypted, with the column master key in Azure Key Vault and key access granted only to the passport office application's identity. Column-level encryption with a certificate in the database would not satisfy the policy because the administrator could open the key.
Can a database owner read data protected by column-level encryption with a certificate in the same database?
Show answer
Yes, if they can open the key, because the keys are stored in the database and decryption happens on the server.
Exam Tips
Remember for the exam
- TDE protects files and backups at rest; queries still see plaintext.
- Column-level encryption: ENCRYPTBYKEY/DECRYPTBYKEY with a symmetric key protected by a certificate.
- Keys stored in the database mean administrators can decrypt.
- Validate the server certificate: Encrypt=True without TrustServerCertificate.