Query Optimization Tips
Use views and stored procedures instead of heavy-duty queries. Try to use constraints instead of triggers, whenever possible. Use table variables instead of temporary tables. Try to use UNION ALL statement instead of UNION , whenever possible. Try to avoid using the DISTINCT clause, whenever possible. Try to avoid using SQL Server cursors , whenever possible. Try to avoid the HAVING clause , whenever possible. If you need to return the total table's row count, you can use alternative way instead of SELECT COUNT(*) statement. Include SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement. Use the select statements with TOP keyword or the SET ROWCOUNT statement, if you need to return only the first n rows. More Tips w...