AlwaysEncrypted error when inserting via stored proc












0















lets start with the error first:



Encryption scheme mismatch for columns/variables . The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '3' expects it to be (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_P_H', column_encryption_key_database_name = 'Payments_Hub') (or weaker)



I'm trying to insert into a column with AlwaysEncrypt encryption on using a stored procedure:



The column 'PARAMETER_VALUE' is the encrypted column



CREATE PROCEDURE dbo.SP_UI_Parameter    
(
@ID int OUTPUT,
@OPERATION_ID int,
@PARAMETER_NAME varchar(100),
@PARAMETER_METRIC varchar(100),
@PARAMETER_VALUE varchar(100)
)
AS
BEGIN

IF @ID IS NULL
BEGIN

INSERT INTO [dbo].[TOKEN_PARAMETER] (OPERATION_ID,
PARAMETER_NAME, PARAMETER_METRIC, PARAMETER_VALUE)

SELECT @OPERATION_ID, @PARAMETER_NAME, @PARAMETER_NAME, @PARAMETER_VALUE

SET @ID = SCOPE_IDENTITY()

END
ELSE
BEGIN

UPDATE [dbo].[TOKEN_PARAMETER] SET
OPERATION_ID = @OPERATION_ID,
PARAMETER_NAME = @PARAMETER_NAME,
PARAMETER_METRIC = @PARAMETER_METRIC,
PARAMETER_VALUE = @PARAMETER_VALUE

END

END
GO


Why am I getting the error for the query ?



Is there something I must include within the STORED PROCEDURE ?




  1. I have included "Column Encryption Setting=Enabled " in my connection settings

  2. I have also enabled Parameteterization for AlwaysEncrypted

  3. The key is stored on the local machine

  4. I have created DETERMINISTIC encryption

  5. SQL Server 2016 database Engine using SSMS 17 - can this be an issue ?


Thanks In Advance









share







New contributor




Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    lets start with the error first:



    Encryption scheme mismatch for columns/variables . The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '3' expects it to be (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_P_H', column_encryption_key_database_name = 'Payments_Hub') (or weaker)



    I'm trying to insert into a column with AlwaysEncrypt encryption on using a stored procedure:



    The column 'PARAMETER_VALUE' is the encrypted column



    CREATE PROCEDURE dbo.SP_UI_Parameter    
    (
    @ID int OUTPUT,
    @OPERATION_ID int,
    @PARAMETER_NAME varchar(100),
    @PARAMETER_METRIC varchar(100),
    @PARAMETER_VALUE varchar(100)
    )
    AS
    BEGIN

    IF @ID IS NULL
    BEGIN

    INSERT INTO [dbo].[TOKEN_PARAMETER] (OPERATION_ID,
    PARAMETER_NAME, PARAMETER_METRIC, PARAMETER_VALUE)

    SELECT @OPERATION_ID, @PARAMETER_NAME, @PARAMETER_NAME, @PARAMETER_VALUE

    SET @ID = SCOPE_IDENTITY()

    END
    ELSE
    BEGIN

    UPDATE [dbo].[TOKEN_PARAMETER] SET
    OPERATION_ID = @OPERATION_ID,
    PARAMETER_NAME = @PARAMETER_NAME,
    PARAMETER_METRIC = @PARAMETER_METRIC,
    PARAMETER_VALUE = @PARAMETER_VALUE

    END

    END
    GO


    Why am I getting the error for the query ?



    Is there something I must include within the STORED PROCEDURE ?




    1. I have included "Column Encryption Setting=Enabled " in my connection settings

    2. I have also enabled Parameteterization for AlwaysEncrypted

    3. The key is stored on the local machine

    4. I have created DETERMINISTIC encryption

    5. SQL Server 2016 database Engine using SSMS 17 - can this be an issue ?


    Thanks In Advance









    share







    New contributor




    Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      lets start with the error first:



      Encryption scheme mismatch for columns/variables . The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '3' expects it to be (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_P_H', column_encryption_key_database_name = 'Payments_Hub') (or weaker)



      I'm trying to insert into a column with AlwaysEncrypt encryption on using a stored procedure:



      The column 'PARAMETER_VALUE' is the encrypted column



      CREATE PROCEDURE dbo.SP_UI_Parameter    
      (
      @ID int OUTPUT,
      @OPERATION_ID int,
      @PARAMETER_NAME varchar(100),
      @PARAMETER_METRIC varchar(100),
      @PARAMETER_VALUE varchar(100)
      )
      AS
      BEGIN

      IF @ID IS NULL
      BEGIN

      INSERT INTO [dbo].[TOKEN_PARAMETER] (OPERATION_ID,
      PARAMETER_NAME, PARAMETER_METRIC, PARAMETER_VALUE)

      SELECT @OPERATION_ID, @PARAMETER_NAME, @PARAMETER_NAME, @PARAMETER_VALUE

      SET @ID = SCOPE_IDENTITY()

      END
      ELSE
      BEGIN

      UPDATE [dbo].[TOKEN_PARAMETER] SET
      OPERATION_ID = @OPERATION_ID,
      PARAMETER_NAME = @PARAMETER_NAME,
      PARAMETER_METRIC = @PARAMETER_METRIC,
      PARAMETER_VALUE = @PARAMETER_VALUE

      END

      END
      GO


      Why am I getting the error for the query ?



      Is there something I must include within the STORED PROCEDURE ?




      1. I have included "Column Encryption Setting=Enabled " in my connection settings

      2. I have also enabled Parameteterization for AlwaysEncrypted

      3. The key is stored on the local machine

      4. I have created DETERMINISTIC encryption

      5. SQL Server 2016 database Engine using SSMS 17 - can this be an issue ?


      Thanks In Advance









      share







      New contributor




      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      lets start with the error first:



      Encryption scheme mismatch for columns/variables . The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '3' expects it to be (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_P_H', column_encryption_key_database_name = 'Payments_Hub') (or weaker)



      I'm trying to insert into a column with AlwaysEncrypt encryption on using a stored procedure:



      The column 'PARAMETER_VALUE' is the encrypted column



      CREATE PROCEDURE dbo.SP_UI_Parameter    
      (
      @ID int OUTPUT,
      @OPERATION_ID int,
      @PARAMETER_NAME varchar(100),
      @PARAMETER_METRIC varchar(100),
      @PARAMETER_VALUE varchar(100)
      )
      AS
      BEGIN

      IF @ID IS NULL
      BEGIN

      INSERT INTO [dbo].[TOKEN_PARAMETER] (OPERATION_ID,
      PARAMETER_NAME, PARAMETER_METRIC, PARAMETER_VALUE)

      SELECT @OPERATION_ID, @PARAMETER_NAME, @PARAMETER_NAME, @PARAMETER_VALUE

      SET @ID = SCOPE_IDENTITY()

      END
      ELSE
      BEGIN

      UPDATE [dbo].[TOKEN_PARAMETER] SET
      OPERATION_ID = @OPERATION_ID,
      PARAMETER_NAME = @PARAMETER_NAME,
      PARAMETER_METRIC = @PARAMETER_METRIC,
      PARAMETER_VALUE = @PARAMETER_VALUE

      END

      END
      GO


      Why am I getting the error for the query ?



      Is there something I must include within the STORED PROCEDURE ?




      1. I have included "Column Encryption Setting=Enabled " in my connection settings

      2. I have also enabled Parameteterization for AlwaysEncrypted

      3. The key is stored on the local machine

      4. I have created DETERMINISTIC encryption

      5. SQL Server 2016 database Engine using SSMS 17 - can this be an issue ?


      Thanks In Advance







      sql-server stored-procedures always-encrypted simple-parameterization





      share







      New contributor




      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      Armandt BurgerArmandt Burger

      83




      83




      New contributor




      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Armandt Burger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Armandt Burger is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f228640%2falwaysencrypted-error-when-inserting-via-stored-proc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Armandt Burger is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Armandt Burger is a new contributor. Be nice, and check out our Code of Conduct.













          Armandt Burger is a new contributor. Be nice, and check out our Code of Conduct.












          Armandt Burger is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f228640%2falwaysencrypted-error-when-inserting-via-stored-proc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Liste der Baudenkmale in Friedland (Mecklenburg)

          Single-Malt-Whisky

          Czorneboh