using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management;
using Microsoft.SqlServer.Management.Smo;
using smo = Microsoft.SqlServer.Management.Smo;


namespace AddTableSMO
{
    class Program
    {
        static void AddTable(string serverName, string databaseName, string tableName, string columnName)
        {
            Server server = new Server(serverName);
            Database database = server.Databases[databaseName];
            Table table = new Table(database, tableName);
            Column column = new Column(table, "ID", DataType.Int);
            column.Identity = true;
            table.Columns.Add(column);
            Index primary = new Index(table, "PK_" + tableName);
            primary.IndexKeyType = IndexKeyType.DriPrimaryKey;
            primary.IndexedColumns.Add(new IndexedColumn(primary, "ID"));
            table.Indexes.Add(primary);
            column = new Column(table, columnName, DataType.VarChar(256));
            table.Columns.Add(column);
            table.Create();
        }

        static void Main(string[] args)
        {
            AddTable(args[0], args[1], args[2], args[3]);
        }
    }
}
