FILESTREAM 数据的物理位置
我如何知道刚刚插入数据库的 FILESTREAM
数据的物理位置(以便我可以在 Windows 资源管理器中看到它)路径?
How could I know the physical location (so I can see it in Windows Explorer) path of a FILESTREAM
data that I've just inserted into DB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
为此有一个选项:方法PhysicalPathName()。如果您现在使用的是 SQL Server 2012 或更高版本,此代码将适合您:
对于 SQL Server 2008/2008 R2,您将需要为整个实例启用跟踪标志 5556:
或者为您调用 PhysicalPathName( 的特定连接) ) 方法:
There is one option for this: method PhysicalPathName(). If you are on SQL Server 2012 or upper now, this code will work for you:
For SQL Server 2008/2008 R2 you will need to enable trace flag 5556 for the whole instance:
or for the particular connection in which you are calling PhysicalPathName() method:
我知道这是一篇较旧的帖子,但由于它在谷歌搜索排名中仍然很高,我想我应该发布一个答案。当然,在更高版本的 SQL 中(我在 2008 年没有尝试过),您可以运行以下查询:
来源
I know this is an older post but as it still comes up high in the Google search rankings I thought I'd post an answer. Certainly in later versions of SQL (I've not tried this on 2008) you can run the following query:
Source
正如 Pawel 所提到的,使用 Windows 资源管理器访问 FILESTREAM 文件并不是一个好主意。如果您仍然决心继续探索这一点,以下提示可能会有所帮助。
FILESTREAM 文件名实际上是创建文件时数据库事务日志中的日志序列号。 Paul Randal 在这篇文章中对此进行了解释。因此,一种选择是找出日志序列号,并在文件流数据容器中查找以该序列号命名的文件。
As Pawel has mentioned, it is not a good idea to access the FILESTREAM files using Windows Explorer. If you are still determined to go ahead and explore this, the following tip might help.
The FILESTREAM file names are actually the log-sequence number from the database transaction log at the time the files were created. Paul Randal has explained it in this post. So One option is to find out the log sequence number and look for a file named after that in the file stream data container.
首先,您需要了解 FileStream 存储在托管 SQL Server 2008 数据库的服务器上。如果您有 DBA,请询问他们在哪里创建 FileStream。当然,您随后需要服务器的权限才能导航服务器以查看目录。您也无法以任何方式操作这些文件,但您将能够看到它们。大多数 DBA 不会热衷于让您知道 FileStream 所在的位置。
但是,您可以通过其他几种方式获取该路径。我想到的一种方法是选择 FileStream 字段的 PathName()。假设FileStream启用的字段是ReportData,并且它所在的表是TblReports。以下 t-sql 语法将生成该位置的 UNC:
我相信您还可以通过企业管理器通过其他方式获取该路径,但我现在忘记了如何操作。
First you need to understand that the FileStream is being stored on the server hosting your SQL Server 2008 database. If you have a DBA, ask them where they created it the FileStream at. Of course, you'll then need rights to the server to navigate it to see the directories. You won't be able to manipulate the files in any way either, but you will be able to see them. Most DBA's won't be keen on letting you know where the FileStream is located at.
However, you can get at the path by a few other means. One way that comes to mind is by selecting upon the PathName() of the FileStream field. Assume that the FileStream enabled field is ReportData, and the table in which it resides is TblReports. The following t-sql syntax will yield an UNC to the location:
I believe you can also get at the path by other means through enterprise manager, but I forget how to at the moment.
--filestream 文件路径
--filestream file path