I have an Azure SQL database that uses the Always Encrypted functionality. In this database I have a column called entryObject. It is an nvarchar field containing JSON data. It is encrypted using a Randomized encryption type.
I am currently writing SQL that should us the JSON_MODIFY function to update this data as well as unencrypted data in another table. I would like to have all of this functionality wrapped in a transaction and in a stored procedure. This way, my C# code can call this one stored proc and, if successful, I'll know that all data was updated successfully. However, any time I try to use the JSON_MODIFY function or even JSON_QUERY with my encrypted entryObject column's data, I get an error stating
Argument data type nvarchar(max) encrypted with (encryption_type = 'RANDOMIZED', ... is invalid for argument 1 of json_query function.
How can I use JSON_MODIFY to change one of the values in this encrypted JSON?
Thanks in advance for any assistance you can give.
Always Encrypted allows clients to encrypt sensitive data inside client applications and never reveal the encryption keys to the Database Engine (SQL Database or SQL Server).
Decryption occurs via the client. This means that some actions that occur only server-side will not work when using Always Encrypted.
SQL Server doesn't know how to decrypt your data. It can't read the value stored in your column, so it can't issue a JSON query against it, let alone modify the value.
You'll need to load the data into your client application, make the changes there, and then update the database value.
You can do that within a transaction, using TransactionScope or BeginTransaction. But you can't do it from a stored procedure.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks for the reply. I was hoping to keep it all in SQL as that's where I was more comfortable with the ability to rollback a transaction in case of failure. I will definitely look into transaction processing in C# and thank you for pointing me in the right direction.
WHAT I INTEND TO ACHIEVE
This is like a loan collection summary.
CID = General Primary Key for every customer
NAME = Customer names
CREDENTIAL = To help me diffentiate between the loan collector and the guarantors, so that I can group in my front end VB application.
BAL = everyone account balance
GID = guarantor for the loan collector, GID is a subset of CID
UNIQUE_ID = A string to combine the CID and the GID for a loan transaction so that I can easily isolate everything about a single loan transaction.
Table A is an abridged form of each loan collection transaction.
Table B carries the account balance for every customer.
Now, I expect Table C to carry all loan record in Table A and use the entries in GID1 and GID2 columns to fetch their corresponding details from Table B while retaining the Unique_ID entries from Table A so that sorting by Unique_ID will bring all loans together.
Please assist me with a way to achieve this, I have been thinking for days, yet no breakthrough.
Thanks in advance
Thanks Richard for your response. Indeed, I have taken a look at the link suggestion. The 2 result sets I have above was achieved using 'Joins'. But achieving 'Table C' is the challenge as I currently can't figure a way out of it.
CID in Table A is always single entry as a customer can't have two running loans as same time and in Table B CID is still single entry as is the account balance of all customers. But Table A.CID is always a subset of Table B.CID.
"guarantor" entries under CREDENTIAL column in Table C is just a string input ( like select 'guarantor' as CREDENTIAL) or (isnull(CREDENTIAL, 'guarantor')) to make me identify that entry as details of a particular guarantor while UNIQUE_ID entries in Table C helps groups individual loan together as both the loan collector and guarantors will have same entries.
CID in Table C can have multiple same values but all entries must be drawn from the primary column Table B.CID
I tried all I could, but still failed to see anyway to directly generate Table C from Table A and B.
I have to generate a new Table D (which looks like Table C - Table A) from my based database tables. Using Table A Union Table D now gives me Table C.
"guarantor" entries under CREDENTIAL column in Table C is just a string input ( like select 'guarantor' as CREDENTIAL) or (isnull(CREDENTIAL, 'guarantor')) to make me identify that entry as details of a particular guarantor.
Since I have gotten a work around for this particular challenge, how do I mark my question as 'Closed' or 'Answered'?
when I execute the code in 2012 SQL Server we are getting following error:
Could not find stored procedure 'sp_set_session_context'. Automation Exception: Could not find stored procedure 'sp_set_session_context'
We tested in 2016 server it is working fine but when we moved to 2012 this is failing. when I searched online I come to know that 'sp_set_session_context' it is new future introduced in 2016, I need relevant commands to implement same in 2012 server..
I need relevant commands to implement same in 2012 server..
The stored procedure itself uses something that doesn't exist in the older version. So that isn't going to help you.
You are not going to easily replace that.
1. It is just a name/value store HOWEVER it is tied to the transaction.
2. So each transaction you would need to 'create' a corresponding store
3. For each transaction you would need to destroy the corresponding store. If you fail to do this you will eventually have a data problem.
4. Then you can use the store, maybe.
I suspect it is easier to just re-write the functionality. I suspect someone just used it so they wouldn't need to pass data around. So pass the data. And/or untie it from the transaction - just tie it to the processes that use it.
I installed ssrs 2013 and made a report and deploy it inro ssrs server,my source database which I used is oracle and I also have oracle client and .net data providet in the same server that ssrs in installed,
When I want to view published reports on the server the following error is rasied:
An error has occurred during report processing. (rsProcessingAborted)
An attempt has been made to use a data extension 'ORACLE' that is either not registered forthis report server or is not supported inthis edition of Reporting Services. (rsDataExtensionNotFound)
could anybody help me out of this?
Last Visit: 31-Dec-99 18:00 Last Update: 17-May-22 2:15