Charles
Thanks a lot
It's similar to the code that Namoi pointed me to, but it's been re-filched!
I can see some real goodies in SMO.
It's like a lot of other good things which you don't know exist until you find a need for them.
>>This is filched directly from an answer on Stackoverflow which I have used
http://stackoverflow.com/questions/650098/how-to-execute-an-sql-script-file-using-c-sharpusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.IO;
using System.Data.SqlClient;
public partial class ExcuteScript : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sqlConnectionString = @"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ccwebgrity;Data Source=SURAJIT\SQLEXPRESS";
FileInfo file = new FileInfo(@"E:\Project Docs\MX462-PD\MX756_ModMappings1.sql");
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
file.OpenText().Close();
}
}
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.