title: Automatic "Script database as... create" for SQL Server 2008
body: <p>I'd like to make a daily automatic creation of the creation script for a database in SQL Server 2008, meaning having a (bat, exe, ... whatever) that creates a text file with the very same output obtained by right-clicking on the database in SQL Management Studio and do Script database as... --> Create to... --> New Query window.</p>
  
  <p>Any hint?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Mauro</p>
  
  <p>EDIT 1: We already used SMO but a couple of things are annoying</p>
  
  <ul>
  <li>Needs compatibility pack in SQL Server 2008 (confirm?)</li>
  <li>Some things were not created in script (some indexes and keys and in table creation schema is lost)</li>
  </ul>
  
  <p>Best choice for me would something with a powershell script but any other idea is welcome!</p>