using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using System.Collections.Specialized;

namespace ScriptOps
{
    class Program
    {
        static void Main(string[] args)
        {
            Server local = new Server();
            local.ConnectionContext.SqlExecutionModes = SqlExecutionModes.CaptureSql;
            local.ConnectionContext.ExecuteNonQuery("INSERT INTO Items VALUES(1))");
            local.ConnectionContext.ExecuteNonQuery("INSERT INTO Items VALUES(2))");
            CapturedSql sql = local.ConnectionContext.CapturedSql;
            StringCollection script = sql.Text;
            foreach (String s in script)
            {
                Console.WriteLine(s);
            }
        }
    }
}
