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

190 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: )

541 reads

Function and Queries to Convert Hierarchical Adjacency to Nested Json Arrays

  • Revision

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-08

1 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.

2018-03-21 (first published: )

935 reads

Blogs

Renewed as a Friend of Red Gate

By

I recently received the news that I’ve been renewed as a Friend of Red...

Redgate Software Needs You!

By

I’ve been very blessed to be able to work for Redgate Software. We’ve done...

Extended Events: Database Auditing

By

Extended Events can do things that simply are not possible with Profiler and another...

Read the latest Blogs

Forums

SSMA 8.6 Unable to find functions in extended stored procedures

By stonechain

I have an instance of SQL Server 2017 (Developer) installed with SSMA for Oracle...

Running generic query for table information

By sizal0234

Hi, I want to run the below query to get information about the tables...

Instance level trigger to store login information (who created what)

By Lord Slaagh

Hello SSC, I am looking for a simplified way to track which user created...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers