title: Programmatically generate script for all objects in a database
body: <p>For an automated setup build that generates the setup for an application which uses Microsoft SQL Server, I am currently evaluating whether the following is possible:</p>
  
  <p>I want to programmatically (CMD script or C# code) execute the function "<a href="http://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/" rel="nofollow noreferrer">Generate Scripts</a>" on a database that is accessible from Microsoft SQL Server Management Studio 2008.</p>
  
  <p>I.e. call some code and have all the objects (tables, SPs, constraints, etc.) of a specified database as an SQL script.</p>
  
  <p>Currently, I only need the structure, not the data.</p>
  
  <p><strong>Question</strong>: Is it possible to achieve this goal?</p>