I created a new stored procedure WITH ENCRYPTION statement, now I want to view its body.
What is the solution?
Keep the script around that created the stored proc in the first place.
There's no documented means of retrieving the text of the procedure once it's been created with this option. There are hints in CREATE PROCEDURE, if you're desperate to recover the text:
ENCRYPTIONIndicates that SQL Server will convert the original text of the
CREATE PROCEDUREstatement to an obfuscated format. The output of the obfuscation is not directly visible in any of the catalog views in SQL Server. Users who have no access to system tables or database files cannot retrieve the obfuscated text. However, the text will be available to privileged users who can either access system tables over the DAC port or directly access database files. Also, users who can attach a debugger to the server process can retrieve the decrypted procedure from memory at runtime.
That is, you'll have to connect using DAC and query undocumented tables - there's certainly no visual option in SSMS.