Find all the path between two nodes of Azure SQL database

priyanka 0 Reputation points
2024-06-26T21:37:52.4866667+00:00

I wan to get columns from association table in SELECT caluse , Is there any other way around for this?

SELECT subgraph, subgraph as name, Typecode,aid,nbr

FROM (

SELECT

i1.Typecode AS Typecode,

i1.ID AS aid,

i1.Number AS nbr,

STRING_AGG(i2.code, '->') WITHIN GROUP (GRAPH PATH) AS subgraph,

LAST_VALUE(i2.code) WITHIN GROUP (GRAPH PATH) AS LastNode,

COUNT(i2.code) WITHIN GROUP (GRAPH PATH) AS levels

FROM en AS i1,

rela FOR PATH AS d,

en FOR PATH AS i2

WHERE MATCH(SHORTEST_PATH(i1(-(d)->i2)+))

) AS Q WHERE Q.Levels = 1

Thanks

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
{count} votes