I have a scenario where I need to encrypt few of the existing columns through "Always Encrypted", but I am in need to do through t-Sql scripts(The tested script needs to be executed in production environment). How could this be done?
Similar to below
ALTER TABLE testTable ALTER COLUMN StringColumn NVARCHAR(20) COLLATE
Latin1_General_BIN2 ENCRYPTED WITH (
ENCRYPTION_TYPE = DETERMINISTIC,
ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256',
COLUMN_ENCRYPTION_KEY = CEK_Auto4)
But,The above code throws the following error
Operand type clash: nvarchar is incompatible with nvarchar(20) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEKName', column_encryption_key_database_name = 'DBName')
Note: I don't have provisions to execute PowerShell scripts. I already have t-SQL script for generating keys