Hi @David Chase ,
Thanks for your update and providing DDL.
Please refer below steps:
Step1: In SSMS, you do that when you’re connecting to the instance in the “Connect to Server” dialog. Select “Options”, and go to “Additional Connection Parameters” and enter into the box “Column Encryption Setting = Enabled” – as per the image below:
Step2: Open a new query window against our database, and then we have to actually enable “Parameterization for Always Encrypted”. Right-click over the query and select “Query Options”, then “Advanced” and enable the option as shown below:
Step3: Get this to work is that you have to rewrite your original query to use variables rather than literal values in the insert. This helps SSMS to be able to manage the rest of the parameterization process.
Please refer my example from below:
--insert into table
DECLARE @fname nvarchar(20) = 'Kula'
DECLARE @ename nvarchar(20) = 'Kalle'
DECLARE @date smalldatetime='2020-10-10'
insert into [dbo].[tblPatients] ([FirstName],[LastName],[dob]) values
(@fname,@ename,@date);
select * from [dbo].[tblPatients]
Output:
--query the value in where condition
DECLARE @fname nvarchar(20) = 'Kula'
select * from [dbo].[tblPatients] where [FirstName]=@fname
Output:
Note: You have to remove 'ORDER BY LastName, FirstName;' from your procedure otherwise you will get the 'Encryption scheme mismatch' errors.
You could refer more details from below links:
Working with Data in Always Encrypted
Query columns using Always Encrypted with SQL Server Management Studio
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.