• If you want to do automate the process of scripting all objects in a database consider SQL Server Database Publishing Wizard. You can execute this program from command line

    Database Publishing wizard fails in the following scenarios

    If the stored procedure is encrypted

    If you use "Execute As user" in stored procedures

    Another way of doing it is using Red Gate Tools. You can script out objects using command line feature of SQL Compare Professional Version (not Standard). This does not give error in the above mentioned scenarios.

    Reddy