Tuesday 15 March 2011

Overview:

When deploying applications to a production server(s) or to a shared SQL Server, there is often a concern that other people might peek at your business logic. Most of the code / business logic resides in Stored procedures.
Below is a mechanism to secure the source code of Stored procedure:
--------------------------
CREATE PROCEDURE [test]
WITH ENCRYPTION
AS
BEGIN
SELECT 'test'
END
--------------------------

1) Any one will not be able to open the procedure in Enterprise Manager's GUI. He will receive the following error:
-----------------------------
Microsoft SQL-DMO
Error 20585: [SQL-DMO]
/******
Encrypted object is not transferable,
and script can not be generated.
******/
-----------------------------
2) You can not get source code with sp_helptext [test]

----------------------------
2 ways I can find the code.
1) Peep in SQL profiler
2) Create new stored procedure.