Sign in to follow this  
Followers 0
archrival

SQL Server 2005 Stored Procedure Decrypt/Export

5 posts in this topic

#1 ·  Posted (edited)

This is a quick and dirty script I wrote using code gathered from the web to export encrypted stored procedures from SQL 2005 (using WITH ENCRYPTION). It will export unencrypted SPs as well. I needed something quick, and this is what I came up with. I would prefer to use DMO instead of sqlcmd for the export, but I've never had luck capturing the output of messages with DMO in AutoIt. This script will currently only export custom SPs, it's possible to remove the query for is_ms_shipped to export all SPs. Feedback and comments welcome and desired.

Edit:

Modified the script, this will now export all encrypted items, not just Stored Procedures. It has been updated to work with the SQL 2008 client tools, although it doesn't appear the decryption code will work against a SQL 2008 server. It will also query the network for all available SQL servers and display a list of all databases on the selected server. It may take some time to find all SQL servers, be patient.

Edit 2:

Modified script to check for DAC before trying to decrypt, also added tooltips for progress indicators.

Edit 3:

Further modified script to properly check for DAC, will no longer exit when DAC connection fails.

See these relevant links about DAC:

Remote Admin Connections

SQL 2005 Trace Flags, -T 7806 is used for SQL Express

Using a Dedicated Administrator Connection

Edited by archrival

Share this post


Link to post
Share on other sites



Why so many FileWriteLine(s) ? Could it be done with one FileWrite? :)

Share this post


Link to post
Share on other sites

Modified code, decrypts all items, has a GUI.

Share this post


Link to post
Share on other sites

Further code updates, also including more information about DAC, please see first post.

Share this post


Link to post
Share on other sites

where is the attachment?

Thx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0