Common Table Expressions (CTE)

Function and Queries to Convert Hierarchical Adjacency to Nested Json Arrays

  • Script

This script converts hierarchical adjacency into nested json rows which contain the recursive "downlines" of each node.  The table-valued function treats each row in the original adjacency as the root node in a recursive common table expression. 

2019-11-24

321 reads

Function and Queries to Convert Hierarchical Adjacency to Nested Json Arrays

  • Script

This script converts hierarchical adjacency into nested json rows which contain the recursive "downlines" of each node.  The table-valued function treats each row in the original adjacency as the root node in a recursive common table expression. 

2019-11-12 (first published: )

725 reads

Stairway to Advanced T-SQL

Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

  • Stairway Step

A CTE is a temporary result set defined by a simple query, and is used within the execution scope of a single INSERT, UPDATE, DELETE, or SELECT statement. In this article we will explore how to define and use CTE's.

2015-03-18

1,338 reads

Blogs

How do I test if a linked server works using T-SQL?

By

I get that linked servers are almost as despised as the dreaded cursor or...

Power BI Monthly Digest – October 2020

By

In this month’s Power BI Digest Matt and I will again guide you through...

Daily Coping 26 Oct 2020

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Read the latest Blogs

Forums

identify sql backup strategies

By mtz676

how do I identify if the dbs are getting backed up (full,diff,log) without looking...

schedule a job in CMS

By mtz676

Is it possible to schedule a sql job in CMS ? As of now...

what does it mean for the following SQL Scripts

By 892717952

in a stored procedure, I found two line sql scripts "    if @@microsoftversion > 0x07320000 exec sp_MSreplraiserror 20598...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers