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”.
- How to Disable Autocommit in SQL Server?
- Create a Logon Trigger to Restrict sysadmin logins to Connect to SQL Server during a given time Interval
- How to Move a Table to another filegroup?
- New T-SQL Functions Introduced in SQL Server 2017
Latest posts by Manvendra Deo Singh (see all)
- Understanding Hybrid Buffer Pool in SQL Server - December 30, 2018
- Fix:VIEW SERVER STATE permission was denied on object ‘server’, database ‘master’ - August 30, 2018
- SQL Server Error 5184: Cannot use file ‘I:\Path\Techyaz.mdf’ for clustered server - August 29, 2018