Overblog Follow this blog
Edit post Administration Create my blog
Balavardhan Reddy Narani

How to encrypt a stored procedure in SQL Server 2005

August 6 2009 , Written by Balavardhan Reddy Published on #SQL Server2005

Inorder to encrypt the text of stored procedures containing sensitive information, Sql Server provides WITH ENCRYPTION to encrypt the Stored Procedure.

CREATE procedure [dbo].[SP_GET_Employee_Details_encrypt]

SELECT EMP_id,First_name,Last_name,Email_id
from Employee
Order by Email_id

Once the stored procedure has been created WITH ENCRYPTION, attempts to view the stored procedure returns a message specifying that the text is encrypted:

EXEC sp_helptext

The text for object 'SP_GET_Employee_Details_encrypt' is encrypted.

One note of caution. Save the original text of the stored procedure before encrypting it, as there is no straightforward way to decode the encrypted text. One hack is to attach a debugger to the server process and retrieve the decrypted procedure from memory at runtime.


Share this post

Repost 0

Comment on this post