I tried creating the stored procedure found here: http://www.mssqltips.com/tip.asp?tip=1046 I created the stored procedure found at the website like this: USE [PBSA_decrypt]GO/****** Object: StoredProcedure [dbo].[DECRYPTSP2K] Script Date: 08/07/2009 09:23:27 ******/SET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGOCREATE PROCEDURE [dbo].[DECRYPTSP2K] (@objName varchar(50))--INPUT: object name (stored procedure, -- -- view or trigger)--Original idea: shoeboy <SHOEBOY@A-- dequacy.org>--Copyright © 1999-2002 SecurityFocus --adapted by Joseph Gama--Planet Source Code, my employer and my-- -- self are not responsible for the use -- of -- this code--This code is provided as is and for ed-- -- ucational purposes only--Please test it and share your results ASDECLARE @a nvarchar(4000), @b nvarchar(4000), @c nvarchar(4000), @d nvarchar(4000), @i int, @t bigint--get encrypted dataSET @a=(SELECT ctext FROM syscomments WHERE id = object_id(@objName))SET @b='ALTER PROCEDURE '+ @objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62)EXECUTE (@b)--get encrypted bogus SPSET @c=(SELECT ctext FROM syscomments WHERE id = object_id(@objName))SET @b='CREATE PROCEDURE '+ @objName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62)--start counterSET @i=1--fill temporary variableSET @d = replicate(N'A', (datalength(@a) / 2))--loopWHILE @i<=datalength(@a)/2 BEGIN--xor original+bogus+bogus encryptedSET @d = stuff(@d, @i, 1, NCHAR(UNICODE(substring(@a, @i, 1)) ^ (UNICODE(substring(@b, @i, 1)) ^ UNICODE(substring(@c, @i, 1))))) SET @i=@i+1 END--drop original SPEXECUTE ('drop PROCEDURE '+ @objName)--remove encryption--try to preserve caseSET @d=REPLACE((@d),'WITH ENCRYPTION', '')SET @d=REPLACE((@d),'With Encryption', '')SET @d=REPLACE((@d),'with encryption', '')IF CHARINDEX('WITH ENCRYPTION',UPPER(@d) )>0 SET @d=REPLACE(UPPER(@d),'WITH ENCRYPTION', '')--replace SPexecute( @d)
I then tried exec sp_helptext mystoredprocedureand I got this: and got this: The text for object 'mystoredprocedure' is encrypted.I then ran this: exec decryptsp2k 'mystoredprocedure'
and it executed successfully. I then ran exec sp_helptext mystoredprocedure
and it cannot find the stored procedure.. in fact, it is gone!!! Does anyone know what I did wrong????