using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
namespace CreateTable
{
    class Program
    {
        static void Main(string[] args)
        {
            Server canopus5 = new Server("CANOPUS5");
            Column col = canopus5.GetSmoObject(
                @"Server[@Name='CANOPUS5']
                /Database[@Name='scratch']
                /Table[@Name='Test456' and @Schema='dbo']
                /Column[@Name='ID']") as Column;
            col.Nullable = false;
            Table t = col.Parent as Table;
            t.Indexes.Add(new Index(t, "id_inx"));
            Index id_inx = t.Indexes["id_inx"];
            id_inx.IndexKeyType = IndexKeyType.DriPrimaryKey;
            id_inx.IndexedColumns.Add(new IndexedColumn(id_inx, "ID"));
            t.Alter();
        }
    }
}
