If a stored procedure returns multiple record sets, and if you are using the DataReader to retrieve the results, you can use the NextResult method of the DataReader to iterate through the Record Sets. Sample shown below:
SqlConnection conn = new SqlConnection("connectionStringValue")); conn.Open(); using (conn) { using (SqlCommand command = new SqlCommand(" SELECT col1 FROM Table1; SELECT col2 FROM Table2", conn)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.HasRows) { while (reader.Read()) { // } reader.NextResult(); } } }}
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.




















