Thursday, November 9, 2017

Sequence of Execution of The SQL Queries


What actually sets SQL Server apart from other programming languages is the way SQL Server processes its code. Generally, most programming language process statement from top to bottom. By contrast, SQL Server processes them in a unique order which is known as Logical Query Processing Phase. These phases and their orders are given as follows:

1. FROM
2. ON
3. OUTER/LEFT/RIGHT/INNER/CROSS Joins
4. WHERE
5. GROUP BY
6. CUBE 
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP


So always think to optimise the data and result top to bottom with this sequence for getting quick results.

1 comment:

  1. Data is the business asset for any organisation which is audited and protected. To gain in their business, it is become very urgent for every organization to choose few good predictive data models and validates them using test data before figuring out an operationalization plan for the model to be deployed to production so that applications can consume it.
    Artificial intelligence with SQL Server

    ReplyDelete

SQL Script to list out name of tables and its records in the database

SET NOCOUNT ON  DBCC UPDATEUSAGE(0)  -- DB size. EXEC sp_spaceused -- Table row counts and sizes. CREATE TABLE #temptable  (      [name] NVA...