Imthiyaz
Imthiyaz

Reputation:

Retrieve previous version of a stored procedure

I have modified a stored procedure today but after that I realized that it is wrong. So I want revert it back. Is there any way to get the previously modified stored procedure or else last date's stored procedure.I don't have any back up also. Thank you.

Upvotes: 3

Views: 17212

Answers (3)

Marc Gravell
Marc Gravell

Reputation: 1063005

Have you any backups of the database itself? The stored procedure is part of the database. Restore it onto a spare machine and extract it from there.

If you don't have a backup of the database... huh???

Upvotes: 1

Remus Rusanu
Remus Rusanu

Reputation: 294307

No, unless the SSMS query window you used to alter the procedure still has the old text in its undo buffer. You must restore a backup copy and manually transfer the procedure from database copy. You shouldn't be updating the database directly, but use a version controlled script instead to start with.

In future you can also install tools like the SSMS Toolpack that keep a history of every query you've run.

Upvotes: 3

ConcernedOfTunbridgeWells
ConcernedOfTunbridgeWells

Reputation: 66622

Not directly within SQL Server. Unless you have kept a script in source control or elsewhere your only option is to restore an older backup to another environment and script out the old version from that.

Upvotes: 6

Related Questions