using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using smo = Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
namespace ScriptTable
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlConnectionInfo info = new SqlConnectionInfo();
             
            ServerConnection conn = new ServerConnection("Test");
            conn.SqlExecutionModes = SqlExecutionModes.CaptureSql;
            
            smo.Server server = new smo.Server(conn);

            smo.Database accounting = new smo.Database(server, "Test");

            smo.Table customers = new smo.Table(accounting, "customers");

            //customers.Parent = accounting;
            smo.Column ID = new smo.Column(customers, "ID");
            ID.DataType = smo.DataType.Int;
            customers.Columns.Add(ID);
            smo.Column Name = new smo.Column(customers, "Name");
            Name.DataType = smo.DataType.NVarChar(35);
            Name.Nullable = false;
            StringCollection script = customers.Script();
            foreach (String s in script)
            {
                Console.WriteLine(s);
            }
            script = accounting.Script();
            Console.WriteLine("+++++++++++");
            foreach (String s in script)
            {
                Console.WriteLine(s);
            }

        }
    }
}
