Given below are little known tips that you can use to ensure your Transact-SQL queries are performing in the most efficient manner possible. 1. Avoid '*' in select query. Restrict the queries result set by returning only the particular columns from the table and not all the table's columns. The sql query becomes faster if you use the actual column names in SELECT statement instead of than '*'. 2. Avoid COUNT(*) in select statement to check the existence of records in table. Instead use IF EXISTS() to check records. - Write the query as: IF EXISTS (SELECT * FROM table_name WHERE column_name = ‘xxx’) - Instead of : SELECT COUNT(*) FROM table_name WHERE column_name = ‘xxx’ 3. Use alternate of SELECT COUNT(*). Use an alternative way instead of the SELECT COUNT(*) statement to count the number of records in table. - SELECT CO...
A blog about software and web app learning/coding, revolving around .net, JavaScript, sql, html, css and whatever technical I found in this beautiful world.