How to Retrieve File Paths from SQL Server FILESTREAM Using GUIDs

m4pnthwp  于 8个月前  发布在  SQL Server
关注(0)|答案(1)|浏览(72)

I'm using SQL Server FILESTREAM to store binary large objects (BLOBs). I have a table that contains a varbinary(max) column and a uniqueidentifier (GUID) column. Each unique identifier corresponds to a specific file in the FILESTREAM.

For example:

GUID D54F345C-56AA-40F6-90DB-A17C23117A40 corresponds to file 00002e64-000002f7-000b
GUID 1BEEA191-D046-48F9-8290-DD193F9BDCB5 corresponds to file 00003a4d-000005be-0003
GUID FCFB269A-6E4C-4A2C-9F0B-2AE7EABD07CF corresponds to file 00000c05-00000058-000a
GUID BC0D325A-6710-4618-B607-79F0A705AB15 corresponds to file 0000317e-000000a9-0003
GUID 30C2376E-0BF5-4321-BB28-25F45B8469DF corresponds to file 00001fed-0000010a-000a

I'm trying to retrieve the file paths for these GUIDs from the database. This seems like a basic task, but I haven't been able to find a straightforward solution online.

Could someone please provide a SQL query or guidance on how to query the database to find the file paths given a GUID?

qyzbxkaa

qyzbxkaa1#

FILESTREAM does not enable access through all the normal filesystem APIs. You can get a file handle to a file with a special API.

See Access FILESTREAM Data with OpenSqlFilestream

If you use the newer File Tables feature, which "can store files and documents in special tables in SQL Server called FileTables, but access them from Windows applications as if they were stored in the file system, without making any changes to your client applications."

相关问题