I am trying to write a query based on users home drives. We have imported a huge CSV inventory of data into an MSSQL, which is basically an inventory of all files each user has within their H drive of which there are over 3000 users and almost 1.4 million files stored between them. I am trying to 'group by' the username, and then get a min and max date (what we would use in Access), of a field called LastWriteTime (type date/time) based one each users home drive, to basically show 'for this users H:\drive this was the first LastWriteTime recorded, and this was the last LastWriteTime recorded. Having the stats per home drive folder would be perfect. So something like...
user - FirstModified - LastModified
\\server\share\user1 - 01/01/2019 - 22/11/2019
\\server\share\user2 - 01/06/2019 - 10/11/2019
The issue/challenge is, the field which represents folder/path (called FullName, type nvarchar(max)) I essentially need to use a segment of the text, e .g. \\server\share\username\ as the unique identifier on which to produce stats on. As entries lower down the inventory will be in format \\server\share\username\folder1\worddoc.docx etc. I am not sure if this would need to be done in multiple stages, but the consistent thing is, the username part would always be that before the 5th back slash, or we could even use the content between the 4th and 5th back slash, e.g. \\server\share\username\ (as everyone's H drive is unique and based upon their AD login name). Given the size of the data I cannot easily do any form of text to columns manipulation in another tool like Excel to extract the username in order to do some min/max date stats, hence we had to get the data into MSSQL in the first place.