I have a database that is being converted to use always-encrypted encryption. I have an Insert inside a stored procedure in the format:
CREATE PROCEDURE CreateUser
(@Username NVARCHAR(50)
,@PaymentMethod NVARCHAR(50))
AS
BEGIN
INSERT INTO Users
( Username
, PaymentMethod
)
VALUES
( @Username
, ISNULL(@PaymentMethod,'Credit Card')
)
END
This is an over simplification, we are actually passing in multiple parameters, and some are encrypted, some aren't.
This code falls over because 'Credit Card' is not encrypted and as such cannot be inserted into an encrypted field, and you cannot encrypt a field with a default constraint. While it is possible to configure a "defaultPaymentMethod" and pass that in too it will make the call very messy.
Does anyone have a more graceful solution than passing in defaults? I'm sure someone has had to do something similar already.
Many thanks.