SQL - Convert non-null adjacency list to path
问题 I am working with some tables that represent a file system, and I need to select the full path of each folder as a flattened string. The first table lists the details of each folder: CREATE TABLE Folders( FolderID int IDENTITY(1,1) NOT NULL, [Name] nvarchar(255) NOT NULL) The second table lists transitive closures of folder relationships: CREATE TABLE FolderClosures( FolderClosuresID int IDENTITY(1,1) NOT NULL, AncestorFolderID int NOT NULL, --Foreign key to Folders.FolderID