Sql-server – Get the old version of stored procedure code in sql server

sql servert-sql

We have modified one of our stored procedures code and accidentally committed it in production DB also. Now we need the older version of the code. Is there any way to get the old version of a stored procedure from the DB? We didn't take any backup of the code. Please help.

Best Answer

To answer you directly.

You cannot get back the old version of the sp , if it is already executed in production, unless you have a backup or you have a customize trigger that logs all execution of sp.

This happens to my team before, that's why we created a trigger that logs all execution. or you can use SQL source control.

The only thing that you can do now is data fix in production.