views:

696

answers:

3

I've ran some "ALTER" scripts on the database [SQL Server Server 2005], and overwrote some sprocs. Is there any way to undo changes and get my old sprocs back?

Is there a way to get the scripts that were executed out of the .LDf file? That way i can re-run my initial "create" script for my sprocs.

I don't have a backup file with old sprocs.

p.s. i backed the DB up as per @Gulzar's deleted answer, and looks like I'm "hosed".

@Pittsburgh DBA: thanx for the solution, but it doesn't seem to work after the backup.

MORAL: Wait for 10 minutes before trying the suggested answers out


Update from Gulzar: What I meant was a file backup before trying anything (to be safe). Not a SQL Server backup.

+4  A: 

FIRST: DO NOT TAKE ANY BACKUPS JUST YET.

There are several tools on the market to do this sort of thing.

You might try this one:

ApexSQL Log

Pittsburgh DBA
I have never used it to recover dropped tables, but the documentation supports the idea that it will do this.
Pittsburgh DBA
Er, stored procedures, too
Pittsburgh DBA
by backing up, i actually meant making copies of the database and log files (as a backup) before trying anything. sql backup was not what i meant.
Gulzar
+1  A: 

And after that, look into using ApexSQLScript to script out your databases on a regular basis (and store in version control).

Cade Roux
+2  A: 

In case anybody else has the same problem - Were you doing transaction log backups every X minutes? If so, you can use Quest LiteSpeed's log reader or Quest Toad for SQL Server's log reader to read the log file backups. It gives undo/redo scripts too for any transaction in the log backups or the ldf.

Brent Ozar