May 2019
Intermediate to advanced
484 pages
11h 23m
English
When writing T-SQL queries, it's important to distinguish between proper join predicates and search predicates.
For inner joins, it is best to keep only join arguments in the ON clause, and move to a WHERE clause for all search arguments. Performance-wise, there is no difference if the generated query plan is the same, but the T-SQL is more readable. The following query examples can be executed in the scope of the AdventureWorks sample database, and yield the same query plans:
SELECT p.ProductID, p.Name, wo.StockedQty, wor.WorkOrderIDFROM Production.WorkOrder AS woINNER JOIN Production.Product AS p ON wo.ProductID = p.ProductIDINNER JOIN Production.WorkOrderRouting AS wor ON wo.WorkOrderID = wor.WorkOrderIDWHERE p.ProductID ...
Read now
Unlock full access