using Microsoft.SqlServer.Management.Smo;<br /> using Microsoft.SqlServer.Management.Common
string sqlConnectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True"; FileInfo file = new FileInfo("C:\\myscript.sql"); string script = file.OpenText().ReadToEnd(); SqlConnection conn = new SqlConnection(sqlConnectionString); Server server = new Server(new ServerConnection(conn)); server.ConnectionContext.ExecuteNonQuery(script);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)