SQLスクリプトを実行するためにC#でSMOを使用しています。ファイルの結果をテキストファイルに出力する必要があります。
コマンドラインを使用してクエリを実行する場合、「-o[出力ファイル]」引数を使用して目的の結果を得ることができます。SMOオブジェクトを使用して同じ操作を実行する方法はありますか?
現時点では、私のコードは単純にSQLスクリプトをサーバーに送信します。
// Read the sql file
string script = sqlFile.OpenText().ReadToEnd();
// Create a new sql connection, and parse this into a server connection.
SqlConnection sqlConnection = new SqlConnection(connectionString);
Server server = new Server(new ServerConnection(sqlConnection));
// Run the sql command.
server.ConnectionContext.ExecuteNonQuery(script);
どんな助けでも大歓迎です!