Executing Multiple SQL Statements Typically, your C# program and the database will run on different computers and communicate over a network. Each time you execute a command in your program | Executing Multiple SQL Statements Typically your C program and the database will run on different computers and communicate over a network. Each time you execute a command in your program it has to travel over the network to the database and be executed by the database and any results must be sent back across the network to your program. That s a lot of network traffic One way to potentially reduce network traffic is to execute multiple SQL statements at a time. In this section you ll see how to execute multiple SELECT statements and retrieve results and you ll see how to execute multiple SELECT INSERT UPDATE and DELETE statements that are interleaved. Executing Multiple SELECT Statements Let s take a look at how you execute multiple SELECT statements and retrieve the results. The following code first creates a SqlCommand object named mySqlCommand and sets its CommandText property to three different SELECT statements SqlCommand mySqlCommand SELECT TOP 5 ProductID ProductName FROM Products ORDER BY ProductID SELECT TOP 3 CustomerID CompanyName FROM Customers ORDER BY CustomerID SELECT TOP 6 OrderID CustomerID FROM Orders ORDER BY OrderID Notice that all of the SELECT statements are separated by semi-colons. Using Table Joins Be careful to retrieve only the rows and columns you actually need. Also make sure you use SELECT statements that retrieve rows from multiple tables. For example if you want to see all the orders placed by the customer with the CustomerID of ALFKI don t perform two separate SELECT statements against the Customers and Orders tables. Instead use a table join as shown in the following SELECT statement SELECT CompanyName OrderlD FROM Customers Orders WHERE AND ALFKI To run earlier SQL statements you call the ExecuteReader method which returns a SqlDataReader object SqlDataReader mySqlDataReader .