SQL ServerManagementStudioのストアドプロシージャ用に「スクリプトを生成」する必要があることがよくあります。生成されたファイルを取得して実行するWPFアプリを作成する必要があります。私はあなたがこれを行うことができることを知っています:
SqlCommand insert = new SqlCommand(sql, conn);
insert.ExecuteNonQuery();
スクリプトファイルのテキスト全体をSQLに渡すと、すべてが実行されますか?
SQL ServerManagementStudioのストアドプロシージャ用に「スクリプトを生成」する必要があることがよくあります。生成されたファイルを取得して実行するWPFアプリを作成する必要があります。私はあなたがこれを行うことができることを知っています:
SqlCommand insert = new SqlCommand(sql, conn);
insert.ExecuteNonQuery();
スクリプトファイルのテキスト全体をSQLに渡すと、すべてが実行されますか?
これを見てください: c# を使用して .SQL スクリプト ファイルを実行する方法
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.IO;
using System.Data.SqlClient;
[...]
private void Execute(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();
}