The following example shows how to create a Tree Path with a Common Table Expression (CTE). First off what is a tree path? For this example I will be referring to the product categories at a camping and fitness store, where you have a top level with 4 categories, and some of the categories have subcategories: Camping Tents 1 Person …

Generating a Tree Path with a CTE Read more »

The following question came up when working on my CTE presentation for SQL Saturday. Does a query that JOINs a CTE to itself execute the CTE query once or twice? For instance:  ;WITH deptCTE(id, department, parent)     AS (SELECT id,department,parent FROM   Departments) SELECT q1.department,q2.department   FROM deptCTE q1  INNER JOIN deptCTE q2 ON q1.id = q2.parent  WHERE q1.parent IS NULL;    The following execution plan is produced showing that the Departments table is hit twice with a table scan …

CTE Query Performance Read more »

After being approved as a speaker at SQL Saturday 114 – Vancouver BC, and SQL Saturday 108 – Redmond WA, I have decided to give it another shot at SQL Saturday 120 in Orange County California. I have submitted 2 abstracts for sessions: The first one is titled Unleashing Common Table Expressions in SQL Server, and if accepted this will be …

Sessions Submitted for SQL Saturday #120 Orange County CA Read more »

Having taught several Introduction to SQL Server classes, it is always a challenge for new users to get SQL Server running on their computer for the first time. I have seen cases where people attempt to download the 90 day trial, if that even exists any more, or to download SQL Express. Here is my recommendation, for developers or anyone …

SQL Server Developer Edition – Under $50 Read more »