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 2, 2013 9:59 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Friday, November 21, 2014 8:24 AM
Points: 462, Visits: 1,506
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 2, 2013 10:21 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Today @ 1:28 PM
Points: 1,469, Visits: 2,774
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 (136 views, 14.01 KB)
Post #1401953
Posted Wednesday, January 2, 2013 11:28 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Friday, November 21, 2014 8:24 AM
Points: 462, Visits: 1,506
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