title: Need SQL CODE for all File/Folder properties including all subfolders, Size in MB, modified/Create/Last access date, Path/Location
body: <p>Need SQL code to find the following details in a Drive/Path: - Folder Name and File Name - Folder Size and File Size in MB - Date Created and Date Modified and Date Accessed - File Flag (1/0) Yes or no based on whether the line item is a file or a folder - Path/URL/Location of the file or folder Need the details for all the folders and sub-folders and files in a given Path/URL</p>
  
  <p>I have multiple codes which provides each of these details individually, but unable to merge it in a single query or join post execution.</p>
  
  <p>Expected output:</p>
  
  <p><a href="http://s6.postimg.org/cn845zwdd/expected_output.jpg" rel="nofollow noreferrer">http://s6.postimg.org/cn845zwdd/expected_output.jpg</a></p>
  
  <p>Parts of the Codes are available in the Blogs as below:</p>
  
  <p><a href="http://sqljourney.wordpress.com/2010/06/08/get-list-of-files-from-a-windows-directory-to-sql-server/#comment-1674" rel="nofollow noreferrer">http://sqljourney.wordpress.com/2010/06/08/get-list-of-files-from-a-windows-directory-to-sql-server/#comment-1674</a> (This link provides a function that gives date modified/path)</p>
  
  <p><a href="https://stackoverflow.com/questions/7952406/get-each-file-size-inside-a-folder-using-sql">Get each file size inside a Folder using SQL</a> (this link provides file size, file flag)</p>
  
  <p>The above links provides parts of the query but i am unable to join them to get them in a single Store procedure..</p>