I want to store a tree of all files and directories in the database.
For my needs, the most appropriate structure for folders is:
CREATE TABLE [Dirs] ([HID] hierarchyid NOT NULL, [FullPath] nvarchar(3800) NOT NULL);
what is the best way to transform a path
into a hierarchyid
?
INSERT INTO [Dirs] VALUES (???, 'c:'), (???, 'c:\Users'), (???, 'c:\Users\User1'), (???, 'c:\Users\User2')