0

I have created a table with two columns (id, name). Encrypted id column using AlwaysEncrypted but now when I am trying to enter a value in id column its throwing this error:

Operand type clash: int is incompatible with int 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 = 'TEST_PS')

What can I do?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • have a look this link that describes the details about the error you are facing and how to use encrypted columns - https://learn.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-ver15. Also refer this link https://stackoverflow.com/questions/44657557/how-to-insert-values-into-a-table-in-sql-2016-whose-columns-are-always-encrypted – Mukesh Arora Dec 19 '19 at 04:13
  • @MukeshArora thankyou. – Priya Sharma Dec 20 '19 at 01:46

1 Answers1

0

From the error msg, it looks like it is trying to insert clear-text into column when it is expecting an encrypted value.

Make sure the INSERT into that column contains a parameter (not clear-text) and the client connection string includes "Column Encryption Setting=enabled". If you are using SSMS make sure "Parameterization for Always Encrypted" is enabled in your Query Options, and variable declaration and value assignment are performed on the same line. See link below for more info.

https://techcommunity.microsoft.com/t5/azure-sql-database/parameterization-for-always-encrypted-using-ssms-to-insert-into/ba-p/386124