Due to the regulation changes in the UK we are changing our Database to use Always Encrypted on all of our person identifiable and potentially sensitive data.
When trying to run a stored procedure after all the Encryption had taken place I received the following error.
Encryption scheme mismatch for columns/variables '@FilePath'. The encryption scheme for the columns/variables is (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'xxxxx') and the expression near line '19' expects it to be (encryption_type = 'PLAINTEXT') (or weaker).
So, when looking into this and commenting out the offending line the SP creates and run's "fine".
Fine in the way that it now has incorrect values.
The offending SQL is :
select @FilePath = ParameterValue from Parameter where ParameterCode = 'EXPORT_PATH'
So, I pulled this line out into its own SQL and not in an SP and got it to work like this.
DECLARE @FilePath VARCHAR(8000) = '',
@ParameterCode varchar(50) = 'EXPORT_PATH'
SELECT @FilePath = ParameterValue from Parameter where ParameterCode = @ParameterCode
SELECT @FilePath
Which works perfectly, however, when I wrap this into an SP like
CREATE PROCEDURE SIMONTEST
AS
BEGIN
DECLARE @FilePath VARCHAR(8000) = '',
@ParameterCode varchar(50) = 'EXPORT_PATH'
SELECT @FilePath = ParameterValue from Parameter where ParameterCode = @ParameterCode
SELECT @FilePath
END
GO
I get the error
Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'PROCEDURE'. Msg 8180, Level 16, State 1, Procedure sp_describe_parameter_encryption, Line 1 [Batch Start Line 0]
Statement(s) could not be prepared.
An error occurred while executing batch. Error message is: Internal error. Metadata for parameter '@p411c14c506c74dc690baf9ef724f7409' in statement or procedure 'CREATE PROCEDURE SIMONTEST AS BEGIN DECLARE @FilePath AS VARCHAR (8000) = @p411c14c506c74dc690baf9ef724f7409, @ParameterCode AS VARCHAR (50) = @p9f3729b1d64742cf858ff9edb30a5d71; SELECT @FilePath = ParameterValue FROM Parameter WHERE ParameterCode = @ParameterCode; SELECT @FilePath; END
' is missing in resultset returned by sp_describe_parameter_encryption.
I would be grateful if someone could help me understand the issue and help me get through it.