|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 3:40 PM
Points: 258,
Visits: 796
|
|
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 12:50 PM
Points: 890,
Visits: 1,859
|
|
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 ----------------------------------------------------------------------------- http://www.sqlservercentral.com/articles/Best+Practices/61537/
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 3:40 PM
Points: 258,
Visits: 796
|
|
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.
|
|
|
|