Generate SQL server scripts from command line?

scripting, sql-server-2008, ssms, windows, wizard

Solution

The script generating options of Management Studio are just a wrapper around the SMO scripting capabilities. Simple scripts are obtained by using the `Script()` method on various SMO types. More complex scripts are created by the specialized `Scripter` class.

Command line tools can be easily created by using the SMO libraries.

Problem

In Microsoft SQL Server Management Studio 2008 there is a "Generate scripts..." option under the Tasks menu. I'm just wondering if this tool is available from the command line somehow? It looks similar to the sqlpubwiz.exe command line tool that was available for SQL Server 2005, but I can't find this executable anywhere in the SQL 2008 installation.

Original source