hi i want to run a script that calls multiple *.sql scripts i have multiple server in lots off sub office will need error control on script if the *.sql crashes also like to use a config file so i can edit for each site
ta Gerard
here some source code i have found
using System.Data.SqlClient;
using System.IO;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string sqlConnectionString = "Data Source=TECHSUP4\\SQLEXPRESS;Initial Catalog=TESTCU;Integrated Security=True";
FileInfo file = new FileInfo("C:\\Database\\Scripts\\test.sql");
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
}