Encrypt stored proceudres with password.

Carlos D 46 Reputation points
2020-09-30T15:23:19.3+00:00

Hi All,
Is there a way to encrypt stored procedure code with password ?. I am not talking about the keyword "WITH ENCRYPTION" in the stored procedure when creating it but actually applying a password to it so that I can also decrypt it with that password. Don't want to create a master key and certificate for it either. Is there a way ? This is for any SQL Server versions from 2012 to 2019.

Thanks.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,756 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 101.4K Reputation points MVP
    2020-09-30T21:55:20.607+00:00

    No. Think of it. To be able to run the stored procedure, SQL Server needs to be able read the SQL code. So if there were such a feature, user would only be able to run the procedure if the user has the password.

    1 person found this answer helpful.
    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Arun Vijayakumar 1 Reputation point
    2020-10-03T03:56:49.533+00:00

    Another way of doing it would be locking the procedure, which is handled by DB Admin. In this way, Company ending their contract will not be able to download or even look at the stored proc's.

    This also helps to reuse if it needs to be implemented in any other company.

    --please don't forget to Accept as answer if the reply is helpful--


  2. Faraz Taha 1 Reputation point
    2021-07-23T06:42:05.173+00:00

    I have same problem, I want to do store procedure encryption with password, want to hide the logic behind the procedures...

    • With Encryption (can easily decrypted by db forge decryptor I tried my self).
    • Procedure Locking will not work as well if it will be on client premises.

    Is there any way around for Procedure encryption with password or any other type of decryption.