Imports Microsoft.SqlServer.Management.Smo ? Allow shorthand notation
Module Module1
  Sub Main()
    Dim s2k5 As New Server() ? Instantiate a Server object
    ? Instantiate a Database object and set the database name
    Dim db As New Database(s2k5, «SqlMag»)
    db.Create() ? Create the database using the Create method
    Dim tab As New Table(db, «DemoTable»)
    ? Instantiate a Column object and set its name and datatype
    Dim col1 As New Column(tab, «Quantity», DataType.Int)
    col1.Nullable = False ? Make the column NOT NULL
    tab.Columns.Add(col1) ? Add the column to Columns collection
    Dim chk1 As 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
    Dim col2 As New Column(tab, «TypeCode», DataType.NChar(2))
    tab.Columns.Add(col2)
    tab.Create()
  End Sub
End Module