{"id":920,"date":"2009-03-17T16:19:00","date_gmt":"2009-03-17T16:19:00","guid":{"rendered":"\/blogs\/paul\/post\/FILESTREAM-directory-structure-where-do-the-GUIDs-come-from.aspx"},"modified":"2017-06-22T06:11:42","modified_gmt":"2017-06-22T13:11:42","slug":"filestream-directory-structure-where-do-the-guids-come-from","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/","title":{"rendered":"FILESTREAM directory structure &#8211; where do the GUIDs come from?"},"content":{"rendered":"<p style=\"text-align: justify;\">I&#8217;m teaching the Microsoft Certified Masters &#8211; Database qualification this week here in Redmond, and in part of day one I discuss the FILESTREAM directory structure. I was asked the question <em>where do the directory name GUIDs come from?<\/em> so I started digging around in the system tables while Kimberly was lecturing. Take a look at my previous blog post (<a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure\/\">FILESTREAM directory structure<\/a>) from last week to see the database schema I&#8217;m working with. I recreated it again and wrote some queries to find where the GUIDs are stored, as they have to be stored in the database somewhere.<\/p>\n<p style=\"text-align: justify;\">Here&#8217;s the query to find all the FILESTREAM directory names, for both levels of directory (and you have to run this through the DAC as it&#8217;s accessing undocumented, hidden system tables):<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nSELECT\r\n    &#x5B;o].&#x5B;name] AS &#x5B;Table],\r\n    &#x5B;cp].&#x5B;name] AS &#x5B;Column],\r\n    &#x5B;p].&#x5B;partition_number] AS &#x5B;Partition],\r\n    &#x5B;r].&#x5B;rsguid] AS &#x5B;Rowset GUID],\r\n    &#x5B;rs].&#x5B;colguid] AS &#x5B;Column GUID]\r\nFROM sys.sysrowsets &#x5B;r] CROSS APPLY sys.sysrscols &#x5B;rs]\r\nJOIN sys.partitions &#x5B;p]\r\n    ON &#x5B;rs].&#x5B;rsid] = &#x5B;p].&#x5B;partition_id]\r\nJOIN sys.objects &#x5B;o]\r\n    ON &#x5B;o].&#x5B;object_id] = &#x5B;p].&#x5B;object_id]\r\nJOIN sys.syscolpars &#x5B;cp]\r\n    ON &#x5B;cp].&#x5B;colid] = &#x5B;rs].&#x5B;rscolid]\r\nWHERE &#x5B;rs].&#x5B;colguid] IS NOT NULL\r\n    AND &#x5B;o].&#x5B;object_id] = &#x5B;cp].&#x5B;id]\r\n    AND &#x5B;r].&#x5B;rsguid] IS NOT NULL\r\n    AND &#x5B;r].&#x5B;rowsetid] = &#x5B;rs].&#x5B;rsid];\r\nGO\r\n<\/pre>\n<p>See below for a screenshot of this using my scenario.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg\" alt=\"\" width=\"1032\" height=\"768\" \/><\/p>\n<p style=\"text-align: justify;\">You can see that I&#8217;m connected through the admin connection in SSMS and that the top-level directory name is derived from the rowset GUID, with the column-level directory name is derived from the column GUID. Note that some parts are byte-reversed, but they&#8217;re definitely the right GUIDs.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m teaching the Microsoft Certified Masters &#8211; Database qualification this week here in Redmond, and in part of day one I discuss the FILESTREAM directory structure. I was asked the question where do the directory name GUIDs come from? so I started digging around in the system tables while Kimberly was lecturing. Take a look [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,86,100],"tags":[],"class_list":["post-920","post","type-post","status-publish","format-standard","hentry","category-filestream","category-sql-server-2008","category-undocumented-commands"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"I&#8217;m teaching the Microsoft Certified Masters &#8211; Database qualification this week here in Redmond, and in part of day one I discuss the FILESTREAM directory structure. I was asked the question where do the directory name GUIDs come from? so I started digging around in the system tables while Kimberly was lecturing. Take a look [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-03-17T16:19:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-22T13:11:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/\",\"name\":\"FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg\",\"datePublished\":\"2009-03-17T16:19:00+00:00\",\"dateModified\":\"2017-06-22T13:11:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg\",\"contentUrl\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FILESTREAM directory structure &#8211; where do the GUIDs come from?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/","og_locale":"en_US","og_type":"article","og_title":"FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal","og_description":"I&#8217;m teaching the Microsoft Certified Masters &#8211; Database qualification this week here in Redmond, and in part of day one I discuss the FILESTREAM directory structure. I was asked the question where do the directory name GUIDs come from? so I started digging around in the system tables while Kimberly was lecturing. Take a look [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/","og_site_name":"Paul S. Randal","article_published_time":"2009-03-17T16:19:00+00:00","article_modified_time":"2017-06-22T13:11:42+00:00","og_image":[{"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg","type":"","width":"","height":""}],"author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/","name":"FILESTREAM directory structure - where do the GUIDs come from? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg","datePublished":"2009-03-17T16:19:00+00:00","dateModified":"2017-06-22T13:11:42+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#primaryimage","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg","contentUrl":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/directoryguids.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/filestream-directory-structure-where-do-the-guids-come-from\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"FILESTREAM directory structure &#8211; where do the GUIDs come from?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=920"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/920\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}