I was exploring Always encrypted feature in SQL Server 2016 in local database. And in our project we were using temp tables extensively in stored procedures, jobs etc.
But when I tried to insert Always Encrypted columns to temp tables, I'm not allowed to do so.
In further research, I have found that the CMK, CEK used in the main database should be used in the tempdb too. So I created same CMK, CEK using ‘create’ statement, in temp database.
But the issue still persists, which is not allowing me to insert AE column data in main table to temp table which is also encrypted using the same keys.
Error getting:Operand type clash: nvarchar(50) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'testDB') is incompatible with nvarchar(50) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'tempdb')
Any help in getting this resolved is much appreciated.