Backup Programmability in SQL Server 2005
0
Q:
Backup Programmability in SQL Server 2005
How can I backup the Programmability (functions, triggers stored procedures etc.) as part of a schedule job? Do I need to write code or can I use the wizard?
ASKED: Feb 20 2008  3:11 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
46795 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
These are backed up when you backup the database itself.

If you wanted to write something to script out the procedures, functions, triggers, etc and save them somewhere you would need to use the sp_helptext procedure within a cursor which gets the object names from the sys.procedures, sys.triggers, and sys.functions DMVs.

declare @name as sysname
declare cur CURSOR for SELECT name FROM sys.procedures
open cur
fetch next from cur into @name
while @@FETCH_STATUS = 0
BEGIN
exec sp_helptext @name
print 'GO'
fetch next from cur into @name
END
close cur
deallocate cur


The above code will print all the code on the screen. If you put this into a job step, and setup the advanced properties of the job step to log the output to a text file, you'll get all the stored procedure T/SQL into a single file. This can be replicated for triggers, functions, etc.
Last Answered: Feb 20 2008  10:22 PM GMT by Mrdenny   46795 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Mrdenny   46795 pts.  |   Feb 20 2008  10:22PM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 

IT Systems Analyst   15 pts.  |   Feb 21 2008  3:04PM GMT

Thank you very much for the help. You are very kind and helpful.

Tzach.

 

Mrdenny   46795 pts.  |   Mar 2 2008  9:44PM GMT

No problem. I’m happy to help.

 
0