An Idea can change your life.....

Wednesday, October 28, 2009

T-SQL Query Processing Order

According to ANSI standard the query should be written in the following way:



SELECT [...]

FROM [table1]

JOIN [table2]

ON [condition]

WHERE [...]

GROUP BY [...]

HAVING [...]

ORDER BY [...]




However the query will be processed by MSSQL in the following order like so:



1. FROM


2. ON

3.OUTER

4.WHERE

5.GROUP BY

6.CUBE
ROLLUP

7.HAVING

8. SELECT

9. DISTINCT

10. TOP

11. ORDER BY

Logical Query Processing Poster

No comments: