Does the Transact-SQL code return more data than needed?
The less data returned by SQL Server, the less resources SQL Server needs to operate, helping to boost the overall performance of SQL Server. This may sound obvious, but returning unnecessary data is a performance problem that I see over and over. Here are some of the most common mistakes made by coders when returning data from SQL Server that results in more data than necessary: • The absence of a WHERE clause. Unless you want to return all data from a table, which is a rare activity, the use of a WHERE clause is necessary to reduce the number of rows returned. • As an adjunct to the above advice, a WHERE clause needs to be a selective as possible. For example, if you only need to return records from a particular date, don’t return all the records for the month, or year. Design the WHERE clause so that exactly only those rows you need returned are returned, and not one extra row. • In the SELECT clause, only include those columns that you need, not all of them. Along the same line, do