title: How can I generate CREATE TABLE script from code?
body: <p>In SQL Server Management Studio, I can generate the <code>CREATE TABLE</code> script for a table by right-clicking a table and choosing <code>Script Table As</code>.</p>
  
  <p>How can I get this same result in C#? Can I utilize SMO or some other methodology?</p>
  
  <p>[To avoid the question getting closed, please post working code samples, not one-liners or links to the high-level documentation.]</p>