Вы можете использовать SqlCommand
, например:
using(var connection = new SqlConnection("connection string"))
using(var command = new SqlCommand(@"
your very long query
", connection)
using(var reader = command.ExecuteReader()) {
while(reader.Read()) {
//use reader[colIndex] to get a field from the current row
}
}
Вы можете загрузить его в таблицу данных, используя SqlDataAdapter
, например:
var table = new DataTable();
using(var connection = new SqlConnection("connection string"))
using(var command = new SqlCommand(@"
your very long query
", connection)
using(var adapter = new SqlDataAdapter(command)) {
adapter.Fill(table);
}