using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Collections.Specialized;
namespace ScriptCapture
{
    class Program
    {
        static void Main(string[] args)
        {
            Server Canopus5 = new Server("CANOPUS5");
            ServerConnection conn = Canopus5.ConnectionContext;
            conn.SqlExecutionModes = SqlExecutionModes.CaptureSql;
            
            Database db = new Database(Canopus5, "Test9999");
            db.DatabaseOptions.AnsiNullsEnabled = true;
            db.DatabaseOptions.RecoveryModel = RecoveryModel.Simple;
            Table customers = new Table(db, "Customers");
            
            Column name = new Column(customers, "Name", DataType.NVarCharMax);
            customers.Columns.Add(name);
            //customers.Create();
            customers.Create();
            db.Create();
            DatabaseRole role = new DatabaseRole(db, "Manage");
            role.Create();
            StringCollection script = conn.CapturedSql.Text;
            foreach (String s in script)
            {
                Console.WriteLine(s);
            }
            
            
        }
    }
}
