I have a fairly detailed description about this problem here: http://sqlity.net/en/1617/decrypting-encrypted-database-objects/
In short, the object is not really encrypted, but rather obfuscated. Therefore we can retrieve the original back. The method is a little involved but it consists of these steps:
- Connect to the instance using the Dedicated Admin Connection (http://technet.microsoft.com/en-us/library/ms178068(v=sql.105).aspx)
select the obfuscated code like this:
SELECT @secret = imageval
WHERE objid = OBJECT_ID(@object_name);
replace the object with another one that has the same name same object_id and the same length in bytes (e.g. using
- get the newly obfuscated code the same way as above
- xor the three values together (obfuscated original, replacement and obfuscated replacement)
That will give you the original code.
However, as Kin mentioned, there might be support and even legal implications with doing this so be sure to consult your lawyer first.