#region Using directives
using Microsoft.SqlServer.Management.Smo; // Allow shorthand notation
#endregion
namespace CreateTable
{
 class Program
 {
  static void Main(string[] args)
  {
   Server s2k5 = new Server(); // Instantiate a Server object
   // Instantiate a Database object and set the database name
   Database db = new Database(s2k5, «SqlMag»);
   db.Create(); // Create the database using the Create method
   Table tab = new Table(db, «DemoTable»);
   // Instantiate a Column object and set its name and datatype
   Column col1 = new Column(tab, «Quantity», DataType.Int);
   col1.Nullable = false; // Make the column NOT NULL
   tab.Columns.Add(col1); // Add the column to Columns collection
   Check chk1 = new Check(tab, «DemoTable_Quantity_chk»);
   chk1.Text = «Quantity > 0»; // Allow only a quantity > 0
   tab.Checks.Add(chk1); // Add check constraint to Checks collection
   Column col2 = new Column(tab, «TypeCode», DataType.NChar(2));
   tab.Columns.Add(col2);
   tab.Create();
  }
 }
}