I'm trying to determine if I can use Always Encrypted on a column in a temporary table (SQL Server 2016 SP1 Enterprise on Windows 2016). I've tried as follows:
CREATE TABLE #listofdates (compare_dt datetime2(7) encrypted with (
COLUMN_ENCRYPTION_KEY = [ColEnc1]
, ENCRYPTION_TYPE = Deterministic
, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'
) NOT NULL
)
However, I get the error:
Msg 33293, Level 16, State 8, Line 3
Cannot find the column encryption key "ColEnc1" because it does not exist or you do not have permissions.
I think this error is misleading, because the statement works if I simply replace table name #listofdates
with another name without the leading # (therefore switching from a temporary table to an ordinary table).
The section on the MS site that lists limits/restrictions on Always Encrypted doesn't mention temporary tables.