How to Protect Stored Procedure Code in SQL Server?

Have you ever thought how to protect stored procedure codes deployed on your SQL Server Instance? When deploying applications to a client’s server(s) or to a shared SQL Server, there is often a concern that other people might peek at your business logic. Since often the code in a stored procedure can be proprietary, it is understandable that we might want to protect our T-SQL work. Here, i will explain how to protect stored procedure from getting displayed its code in sp_helptext command.

We can use “WITH ENCRYPTION” option to protect our T-SQL code. Have a look at below SQL code that i have been used to protect my stored procedure.

CREATE PROCEDURE dbo.Manvendra
WITH ENCRYPTION
AS
BEGIN
SELECT 'SQL statements'
END

Now when you will try to run sp_helptext to see the code, below error will appear.

“The text for object ‘Manvendra’ is encrypted”.

Read Articles:

I hope you like his tip. You can drop your questions and feedbacks in comment section given below. You can also follow our Facebook page and Twitter handle to get latest updates.

Manvendra Deo Singh
Follow me:

Manvendra Deo Singh

I am working as a Technical Architect in one of the top IT consulting firm. I have expertise on all versions of SQL Server since SQL Server 2000. I have lead multiple SQL Server projects like consolidation, upgrades, migrations, HA & DR. I love to share my knowledge. You can contact me on my social accounts for any consulting work.
Manvendra Deo Singh
Follow me:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *