sql server - Use Always Encrypted on decimal(18,2) -


i using new sql server 2016 feature - encrypted. cool , simple technology - not decimal type.

when insert value, getting errors 1 (zp_test - db name):

operand type clash: decimal(4,2) encrypted (encryption_type = 'randomized', encryption_algorithm_name = 'aead_aes_256_cbc_hmac_sha_256', column_encryption_key_name = 'colomnkey', column_encryption_key_database_name = 'zp_test') incompatible decimal(18,2) encrypted (encryption_type = 'randomized', encryption_algorithm_name = 'aead_aes_256_cbc_hmac_sha_256', column_encryption_key_name = 'colomnkey', column_encryption_key_database_name = 'zp_test')
statement(s) not prepared.

my api written in c#, please see code maybe know solution.

sql query creating table

create table [dbo].[empinfo] (     [empid] [int] null,     [natid] [nvarchar](max) collate cyrillic_general_bin2 encrypted (column_encryption_key = [colomnkey], encryption_type = randomized, algorithm = 'aead_aes_256_cbc_hmac_sha_256') null,     [amount] [decimal](18, 2) encrypted (column_encryption_key = [colomnkey], encryption_type = randomized, algorithm = 'aead_aes_256_cbc_hmac_sha_256') null ) on [primary] go 

c# code example

command.commandtext = "insert empinfo(empid, natid, amount) values (@key, @ssn, @amount)";  command.parameters.addwithvalue("@key", key); command.parameters.addwithvalue("@ssn", dbnull.value); command.parameters.addwithvalue("@amount", convert.todecimal("11.00")); command.executenonquery(); 

trace in sql, when error occurs -

exec sp_describe_parameter_encryption n'insert empinfo(empid, natid, amount, amountdec) values (@key, @ssn, @amount, @amountdec)',n'@key int,@ssn nvarchar(7),@amount decimal(4,2)' 

please specify decimal's precision , scale using sqlparamater object follows

sqlparameter param = new sqlparameter("@amount", sqldbtype.decimal); param.precision = 18; param.scale = 2; command.parameters.add(param); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -