SQL Server How to retrieve JSON data from encrypted column

hc2pp10m  于 2023-06-21  发布在  其他
关注(0)|答案(1)|浏览(105)

I'm trying to get JSON data from an encrypted column using sql server, but i'm finding out that every JSON related function i try on the column (IS_JSON, JSON_QUERY, JSON_VALUE) returns an error :

Argument data type nvarchar(max) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = '***', column_encryption_key_database_name = '***') is invalid for argument 1 of isjson function.

If i try to retrieve the data as plain text nothing to worry about, but if i try to select the json data inside it, it throws the error.

This is an example of query that throws the error

select ISJSON(wbmalert.AlertDetailJson)
from wbmalert

Cannot understand why and how to fix it.

jljoyd4f

jljoyd4f1#

You can't do this on the server-side.

The whole point of Always Encrypted is that the server has no idea what is inside the column, and cannot decrypt it. Only the client can do so as it has the encryption key.

When you query the column directly, the client driver understands that it's encrypted and transparently decrypts it.

While using a Secure Enclave could work for some operations, I don't think ISJSON is supported. And whether Secure Enclave will be right for your encryption requirements is another question.

相关问题