How to automatically script-out all objects in database ?

  • 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

  • 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[/url]

  • 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.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply