WOW, what a great day at SQL Saturday 108 in Redmond.  I started out with a keynote presentation from Buck Woody.  Then I delivered my  presentation on Common Table Expressions.  Which I think went well.  There were some great questions and I look forward to refining my presentation to include some of the questions that I was asked at the …

A Great Day at SQL Saturday 108 in Redmond. Read more »

Queries with Common table expressions (CTE) are made up of two parts, the CTE part, and the SQL that references the CTE.  In preparation for SQL Saturday, the question came up of can you use an INSERT or UPDATE statement with a CTE.  Referring to the documentation I confirmed that using an insert or update inside of the CTE is …

CTE – With An Insert Statement Read more »

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 »