Steve Collins


Technical Article

Function and Queries to Convert Hierarchical Adjacency to Nested Json Arrays

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. 

You rated this post out of 5. Change rating

2019-11-25 (first published: )

715 reads

Technical Article

Function and Queries to Convert Hierarchical Adjacency to Nested Json Arrays

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. 

You rated this post out of 5. Change rating

2019-11-12 (first published: )

1,975 reads

Blogs

Convert SQL Audit Files to a CSV Using Read-SqlXEvent

By

SQL Server Audit is an efficient way to track and log events that occur...

Control Flow Restartability in Azure Data Factory

By

I presented at SQL Saturday Pittshburgh this past weekend about populating your data warehouse...

Monday Monitor Tips: Knowing Your RPO

By

A customer was asking recently about the RPO for their estate, and I showed...

Read the latest Blogs

Forums

Getting all ancestral parents of a table

By jaango123

From this link - https://stackoverflow.com/questions/22005698/how-to-find-all-the-dependencies-of-a-table-in-sql-server I can find all the child dependencies starting from my...

Average Height For A Man In India

By deepak650ku

The average height for a man in India is approximately 5 feet 5 inches...

Limb Lengthening Surgery Cost in India

By deepak650ku

Limb lengthening surgery in India is a specialized orthopedic procedure aimed at increasing the...

Visit the forum

Question of the Day

STRING_AGG's behavior

Executing the following script (Sql Server 2022), you get the table t0 with 10 rows:
CREATE TABLE t0
( id     INT PRIMARY KEY
, field1 VARCHAR(1000)
, field2 VARCHAR(MAX));
INSERT INTO t0
SELECT
  gs.value
, REPLICATE ('X', 1000)
, REPLICATE ('Y', 1000)
FROM generate_series(1, 10, 1) gs;
GO
What happens if you execute the following statements?
  1. select STRING_AGG(field1, ';') within group (order by id)  from t0;
  2. select STRING_AGG(field2, ';') within group (order by id)  from t0;

See possible answers