What happens !!! – Processing of SQL statements

Ever wonder when you fire any of SQL statement, how SQL server process them, and fires in db ? Here is some of them which I got just

Processing order of a SELECT statement.

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. GROUP BY
  6. HAVING
  7. SELECT
  8. DISTINCT
  9. ORDER BY
  10. TOP

When Insert Statements are fired.

  1. IDENTITY Insert check
  2. Not Null Constraint Validation.
  3. Data Type Verification
  4. Instead of trigger execution If it exists.
  5. Primary key Constraint Validation
  6. Check Constraint Validation
  7. Foreign Key Constraint Validation
  8. After Trigger Execution

Good way to know this is just write this when executing your query :

SET STATISTICS PROFILE ON

<< your sql statement >>>

SET STATISTICS PROFILE OFF

Few other options like this are which are mostly used for performance enhancements are

SET STATISTICS IO ON

SET STATISTICS TIME ON

SET STATISTICS XML ON