snippetsqlMinor
How to backup the current code of a stored procedure and its permissions as well?
Viewed 0 times
storedthepermissionsandprocedureitswellcurrenthowcode
Problem
I often get requests to alter stored procedures, in both test, development and production environments.
I would like a simple way to save the current code of the stored procedure, before the changes, into a table in my "tablebackups" database - which is a database where I save records prior to update or delete them.
I am thinking about something like this:
the idea of usage is something like this:
has someone got a solution for this already developed?
I would like a simple way to save the current code of the stored procedure, before the changes, into a table in my "tablebackups" database - which is a database where I save records prior to update or delete them.
I am thinking about something like this:
sp_helptext 'sp_myprocedure'the idea of usage is something like this:
select * into tablebackups.dbo.my_procedure_20150827_1220
from ss_save_my_procedure 'my_procedure'has someone got a solution for this already developed?
Solution
Rather than saving your procedures in user tables, why don't you just set up a SSDT database project and use version control (TFS, Git, Mercurial, SVN or whatever you find appropriate) to take care of versioning?
SSDT or other tools such as Red Gate's SQL Source Control will help you in keeping track of versions and deploying your changes to your envirnoments.
SSDT or other tools such as Red Gate's SQL Source Control will help you in keeping track of versions and deploying your changes to your envirnoments.
Context
StackExchange Database Administrators Q#112393, answer score: 7
Revisions (0)
No revisions yet.