powershelldba.de · Uwe Janke

Encrypting SQL Server: Options, Prerequisites, and What Existing Applications Won't Let You Do

Database encryption is turning from "nice to have" into a standing requirement, driven by regulation, customer contracts, and cyber-insurance questionnaires that no longer accept "we have a firewall" as an answer. SQL Server offers several genuinely different ways to encrypt, not one obvious default, and picking the wrong one for the threat model is how a project burns a quarter re-architecting queries it didn't need to touch.

Start With the Threat Model, Not the Feature Name

"Encrypt the database" means different things depending on who is asking, and each SQL Server feature answers a different version of the question. Before picking one, be clear on what you're actually defending against:

ThreatWhat addresses it
A stolen physical disk, storage snapshot, or backup fileTDE, or storage/backup-target encryption outside SQL Server
Network traffic sniffed between client and serverTLS / Force Encryption
A DBA, cloud provider, or anyone with normal query access seeing a specific sensitive columnAlways Encrypted, or manual cell-level encryption
An offsite or third-party backup target that shouldn't be able to read the backup contentsBackup encryption (with or without TDE)
"We got breached, but the attacker only got table names, not row values"None of these alone; encryption doesn't substitute for access control and patching

None of these is "the" answer. A realistic compliance posture usually needs several of them layered, not one chosen instead of the others.

Encryption at Rest: Transparent Data Encryption (TDE)

TDE encrypts the physical data and log files at the page level, transparently to every query, application, and report already pointed at the database. Nothing in the application layer has to change. It moved from Enterprise-only into Standard Edition starting with SQL Server 2019, which removed the biggest historical barrier to adopting it.

The entire operational risk lives in one place: the certificate protecting the database encryption key lives in master, not in the database itself, and a database restored elsewhere without that certificate is permanently unreadable, with no recovery path. This site already covers TDE in depth, so rather than repeat it:

The AlwaysOn case deserves a callout here specifically because it's the same recurring pattern this blog keeps coming back to: a server-scoped object doesn't travel with the database through an AG. Server logins don't (see AlwaysOn with Standard vs. Contained Databases), and neither does the TDE certificate. Add an encrypted database to an AG without creating the identical certificate on every secondary first, and that secondary simply cannot bring the database online.

Encryption in Use: Always Encrypted

TDE's blind spot is exactly what Always Encrypted (SQL Server 2016+) is built for: data that stays encrypted everywhere, on disk, in memory, on the network, and in the query plan, decrypted only inside the client driver, using a key SQL Server itself never has access to. A sysadmin running SELECT * FROM Customers sees ciphertext in the encrypted columns, not plaintext.

Two encryption types, with a real tradeoff:

Keys: a Column Master Key (CMK) stored outside SQL Server entirely (Windows certificate store, Azure Key Vault, or an HSM), and a Column Encryption Key (CEK) stored inside the database but itself encrypted by the CMK. SQL Server only ever sees the encrypted CEK; it never sees a key capable of decrypting data.

-- The client driver does the actual encrypt/decrypt work; SQL Server only
-- stores and returns ciphertext. Requires the connection string flag:
-- "Column Encryption Setting=Enabled"

ALTER TABLE dbo.Customers
ALTER COLUMN NationalId varchar(20)
ENCRYPTED WITH (
    COLUMN_ENCRYPTION_KEY = CEK_Customers,
    ENCRYPTION_TYPE = DETERMINISTIC,
    ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'
);

Encrypting Backups, Independently of TDE

If a database isn't TDE-encrypted but its backups leave the building, to offsite storage, a cloud backup target, or a managed service provider, BACKUP ... WITH ENCRYPTION encrypts the backup file itself using a certificate or asymmetric key, available in Standard Edition since SQL Server 2014:

BACKUP DATABASE ProductionDB
TO DISK = 'D:\Backup\ProductionDB.bak'
WITH ENCRYPTION (
    ALGORITHM = AES_256,
    SERVER CERTIFICATE = Backup_Cert
), COMPRESSION;

The same rule as TDE's certificate applies here without exception: the certificate encrypting the backup has to be backed up and stored separately from the backups it protects, or those backups become exactly as unrecoverable as the TDE scenario. If TDE is already on, backups inherit that encryption automatically; explicit backup encryption is for the case where TDE is off, or as a deliberate second layer.

Encryption in Transit: TLS / Force Encryption

Everything above protects data sitting somewhere. None of it protects data moving between the application and SQL Server over the network, that's a separate setting entirely: Force Encryption on the instance, backed by a real certificate.

The self-signed default is not the same as a validated connection SQL Server generates a self-signed certificate automatically and will encrypt connections with it if asked, but a self-signed certificate proves nothing about the server's identity to a client that isn't separately configured to trust it. A client connecting with Encrypt=True and TrustServerCertificate=True gets an encrypted channel to whoever answered on that port, not a verified connection to the real server, which is exactly the gap a man-in-the-middle attack lives in. Force Encryption is only as good as the certificate behind it and the client actually validating that certificate's chain.
sqmSQLTool: Set-sqmSqlTlsCertificate binds a proper certificate from the machine store to SQL Server, Install-sqmCertificate and New-sqmCertificateRequest handle getting one issued in the first place, and Get-sqmCertificateReport tracks expiration across an instance so Force Encryption doesn't silently fail the day a certificate lapses.

The Manual Predecessor: Cell-Level Encryption Functions

Before Always Encrypted existed, column-level encryption meant calling ENCRYPTBYCERT, ENCRYPTBYASYMKEY, ENCRYPTBYKEY, or ENCRYPTBYPASSPHRASE explicitly in T-SQL, storing the result as varbinary, and decrypting explicitly with the matching DECRYPTBY... function on every read. It still works, on every edition, and is occasionally still the right answer on an older version or an edition where Always Encrypted's driver requirements aren't met, but it comes with none of Always Encrypted's automation: the application has to know which columns are encrypted and call the right function on both write and read, the column can't be indexed, searched, or sorted at all (it's an opaque binary blob to the engine), and key management is entirely manual.

What Existing Applications Won't Let You Do

This is where an encryption project actually gets expensive, not in the SQL Server configuration itself.

Always Encrypted's real constraints

TDE's constraints are lighter, but not zero

What's Actually Sensible

The Risks That Don't Make the Compliance Slide

Lost key material is not a recoverable incident, for any of these methods A missing TDE certificate, a missing backup encryption certificate, or a missing Always Encrypted Column Master Key all end the same way: the data is not damaged, it is gone, with no vendor support path back to it. Every one of these projects needs a key-backup and key-recovery plan before the encryption itself goes live, not after.

Comparison

Aspect TDE Always Encrypted Backup encryption TLS in transit
Protects against Stolen disk/backup Anyone with query access, incl. DBAs Stolen/exposed backup file Network interception
Application changes needed None Driver upgrade + query rewrites for encrypted columns None Connection string flags only
Edition requirement Standard 2019+, or Enterprise Basic: any edition. Enclaves: typically Enterprise Standard 2014+, or Enterprise All editions
Query capability on protected data Unaffected Limited to none, depending on encryption type N/A (data at rest only) Unaffected
Dominant risk if mismanaged Lost certificate = unreadable database Lost CMK = unreadable columns; broad rollout stalls projects Lost certificate = unreadable backups Self-signed cert = false sense of security
Full command reference: Every sqmSQLTool function referenced above is documented at sqmSQLTool commands. Note what's not yet wrapped: TDE certificate lifecycle and Always Encrypted key/column management are run as plain T-SQL today, exactly as shown in this article.

Questions People Actually Ask

Q: Does TDE stop a DBA or an application from reading the data? No. TDE encrypts the physical data and log files at rest. Any authenticated query, whether from the application or a DBA with normal access, sees plaintext, because SQL Server decrypts pages transparently as they move into the buffer pool. Stopping specific people or roles from seeing specific columns, even with full database access, requires Always Encrypted or cell-level encryption instead.
Q: Can I run WHERE and LIKE queries against an Always Encrypted column? It depends on the encryption type. Deterministic encryption supports equality comparisons and joins, but not ranges, LIKE, or sorting. Randomized encryption, the more secure option, supports none of these operations at the database engine level at all. Secure enclaves relax this by allowing richer operations, but add their own infrastructure and edition requirements.
Q: Do I need Enterprise Edition to encrypt a SQL Server database? Not necessarily. Transparent Data Encryption moved into Standard Edition starting with SQL Server 2019, and backup encryption without TDE has been available in Standard Edition since SQL Server 2014. Always Encrypted's basic form works on any edition with a compatible client driver; secure enclaves are the piece most likely to require Enterprise Edition, so check the specific SQL Server version's licensing documentation before planning around them.
Q: What happens to backup compression when TDE is enabled? It largely stops working. Encrypted data is close to random from a compression algorithm's point of view, so a compressed backup of a TDE-enabled database typically comes out close to the same size as an uncompressed one. This is a real capacity-planning cost, not a theoretical one, and it applies whether TDE's own transparent compression-then-encryption path is used or not, since the encryption happens at the page level before the compression pass has anything patterned left to work with.