Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to automatically script-out all objects in database ? Expand / Collapse
Author
Message
Posted Wednesday, January 02, 2013 9:59 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 17, 2014 9:10 AM
Points: 360, Visits: 1,136
Hi all,

I need to automatically script out all objects from a databases similarly like in SSMS context menu in <Database>/Tasks/Generate scripts.

Here is the reason for it: this is development server. I have a job where once a week I run restore from prod backup, but developers usually forget to save their work in TFS. In order to prevent losing their work, I want to script out all the contents of database priorly to restore.

Thanks
Post #1401941
Posted Wednesday, January 02, 2013 10:21 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 5:48 AM
Points: 1,264, Visits: 2,393
attached is a powershell script I have used to script out all objects. This scripts all objects to their own file you can adjust the $Scripter.Options.FileName option. The script either accepts a text file with a list of servers or if a file is not supplied it will run with the local instance.

Bob
-----------------------------------------------------------------------------
How to post to get the best help


  Post Attachments 
scripter.txt (126 views, 14.01 KB)
Post #1401953
Posted Wednesday, January 02, 2013 11:28 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, April 17, 2014 9:10 AM
Points: 360, Visits: 1,136
Thanks a lot Robert.

This is great solution. I did not run it yet, I am not very proficient in Powershell, I will let you know about results.
Post #1401992
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse