473,422 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

How to Decrypt the Stored Procedure in Sql Server 2008?

Hi to all


One of my collegue was created that sp's now i want to manage all those things, i dont know how to decrypt the procedure's, we lost the copy of that procedure.

I am using the following code to decrypt my procedure, but it did'nt work to get the procedure it always give the null value.

Expand|Select|Wrap|Line Numbers
  1.  
  2. create  PROCEDURE sp_decrypt_sp (@objectName varchar(50))
  3. AS
  4. DECLARE  @OrigSpText1 nvarchar(4000),  @OrigSpText2 nvarchar(4000) , @OrigSpText3 nvarchar(4000), @resultsp nvarchar(4000)
  5. declare  @i int , @t bigint , @ct nvarchar(max)
  6.  
  7. --get encrypted data
  8. SET @OrigSpText1= (SELECT top 1 ctext FROM syscomments  WHERE id = object_id(@objectName) order by colid)
  9. SET @OrigSpText2='ALTER PROCEDURE '+ @objectName +' WITH ENCRYPTION AS '+REPLICATE('-', 3938)
  10. EXECUTE (@OrigSpText2)
  11. print @OrigSpText1
  12.  
  13. SET @OrigSpText3=(SELECT top 1 ctext FROM syscomments  WHERE id = object_id(@objectName) order by colid)
  14. SET @OrigSpText2='CREATE PROCEDURE '+ @objectName +' WITH ENCRYPTION AS '+REPLICATE('-', 4000-62)
  15.  
  16. --start counter
  17. SET @i=1
  18. --fill temporary variable
  19. SET @resultsp = replicate(N'A', (datalength(@OrigSpText1) / 2))
  20.  
  21. --loop
  22. WHILE @i<=datalength(@OrigSpText1)/2
  23. BEGIN
  24. --reverse encryption (XOR original+bogus+bogus encrypted)
  25. SET @resultsp = stuff(@resultsp, @i, 1, NCHAR(UNICODE(substring(@OrigSpText1, @i, 1)) ^
  26.                                 (UNICODE(substring(@OrigSpText2, @i, 1)) ^
  27.                                 UNICODE(substring(@OrigSpText3, @i, 1)))))
  28. print @resultsp
  29.  SET @i=@i+1
  30. END
  31. --drop original SP
  32. --EXECUTE ('drop PROCEDURE '+ @objectName)
  33. --remove encryption
  34. --preserve case
  35. SET @resultsp=REPLACE((@resultsp),'WITH ENCRYPTION', '')
  36. SET @resultsp=REPLACE((@resultsp),'With Encryption', '')
  37. SET @resultsp=REPLACE((@resultsp),'with encryption', '')
  38. IF CHARINDEX('WITH ENCRYPTION',UPPER(@resultsp) )>0 
  39.   SET @resultsp=REPLACE(UPPER(@resultsp),'WITH ENCRYPTION', '')
  40. --replace Stored procedure without enryption
  41. set @ct = (SELECT ctext FROM syscomments WHERE id = object_id(@objectName))
  42. print @ct
  43. execute( @resultsp)
  44. GO
  45.  
  46.  
Thanks to all
Sep 20 '10 #1
2 4948
NeoPa
32,556 Expert Mod 16PB
The point of encryption is to stop anyone from getting to the encrypted data. I'm afraid we cannot help you here. Our rules forbid it.
Sep 20 '10 #2
ck9663
2,878 Expert 2GB
If your collegue uses the "WITH ENCRYPTION" clause/option when he created the SP, the encryption used is a built-in SQL Server feature and can not be decrypted. If he uses his own encryption, you're going to have to ask him.

Good Luck!!!

~~ CK
Sep 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
0
by: bobby_b_ | last post by:
Hello, I'm trying to access a stored procedure on our AS400 that is written in RPG. I know that the stored procedure works (I've called it from an RPG program on the AS400), and I know that the...
2
by: fperri | last post by:
I am using SQL Server 2005 and SQL Server Management Studio Express. I'm new to stored procedures and I was creating this one to test out the BULK INSERT sql command. When I execute it says...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: zaza24 | last post by:
Hello there I am loosing my time since a few days trying to install a CRM (ACT! 2008 version 10) software on a brand new HP notebook with Vista prof OS. Ths installation do not show any...
20
by: billmaclean1 | last post by:
I need to write a stored procedure that selects from a table and returns the result set. I don't always know the TableSchema that I need to use when qualifying the table at run-time Example:...
2
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could...
12
by: barmatt80 | last post by:
I don't know if this is the right part of the forum. But.... I have been working all night trying to create a web service to call a stored procedure in sql server 2008. The stored procedure calls...
3
by: cmrhema | last post by:
Hi, Kindly excuse if I am posting in the wrong place. I am using Visual Studio 2008, .net framework 3.5, asp.net , c# and sql server 2005. I am supposed to pass stored procedures from client...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.