How to tie filestream GUID value to actual file name?

chrisrdba 431 Reputation points
2022-05-11T22:59:25.88+00:00

Greetings. I've seen a few people ask this question on google w no real solution.

We're using filestream, and I want to run a query in the DB that will allow me to tie the result of that query to the actual name of the filestream file.

This link shows the column filestream_value_name which is precisely what I'm after, but only shows stuff waiting to be backed up, while running in DAC. I need something that can tie every row of data in my table to the actual file name as seen in Explorer (for example).

I'm also aware of column.pathname , but that doesn't truly show what I need.

I'm also aware that manually manipulating these files is not supported, and could lead to corruption. I have no intention of doing that.

Any ideas?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,121 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 113.3K Reputation points MVP
    2022-05-13T20:26:05.027+00:00

    It may be better to play it safe and write a program that trawls the Filestream table and extracts the files with the OpenSqlFilestream API and writes the file and the metadata. Yes, this means that you need to find a programmer that can write such a program. Then again, this is not 200 lines of code.

    This also gives you a consistent view of the contents. If you read the raw file area directly, you will get old versions and deleted files that have not been garbage-collected yet.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.