SQL SERVER – Effect of Order of Join In Query

Let us try to understand this subject with example. We will use Adventurworks database for this purpose. Table which we will be using are HumanResources.Employee (290 rows), HumanResources.EmployeeDepartmentHistory (296 rows) and HumanResources.Department (16 rows). We will be running following two queries and observe the output. In the resultset the order…
Read More

SQL SERVER – SQL SERVER – Simple Example of Recursive CTE – Part 2 – MAXRECURSION – Prevent CTE Infinite Loop

Yesterday I wrote about SQL SERVER – SQL SERVER – Simple Example of Recursive CTE. I right away received email from regular reader John Mildred that if I can prevent infinite recursion of CTE. Sure! recursion can be limited. Use the option of MAXRECURSION. USE AdventureWorks GO WITH Emp_CTE AS…
Read More