Dev Kashyap
Dev Kashyap

Reputation: 425

Encrypt the stored procedure in sql to improve the security of database

I want to improve the security of my database, so I want to know what I should do.

And how I can encrypt the stored procedures.

Thanks in advance...

Upvotes: 0

Views: 143

Answers (2)

Curtis
Curtis

Reputation: 103338

Use WITH ENCRYPTION

ALTER PROCEDURE [dbo].[sp_ProcedureName]
WITH ENCRYPTION
AS
BEGIN
    SET NOCOUNT ON;

      SELECT ...

END

Never encrypt development procedures though as you cannot decrypt these easily!

Upvotes: 2

Oded
Oded

Reputation: 498904

You will need to write a procedure that decrypts the stored procedure and execute it - anyone with access to the database will also be able to access this procedure, so you gain nothing by encrypting a stored procedure.

There are well established practices regarding database security - follow them.

Some of them are:

  • Give minimal permissions
  • Use different user logins
  • Do not use sa

Upvotes: 6

Related Questions