SQL Server:加载目录树的快速方法(名称、修改日期)
(我寻找答案,但到目前为止没有真正解决我的问题。)
我想用 Microsoft SQL Server 2005 中的文件目录树保持表最新。我现在执行规范:
insert into #resultTable (Path)
exec master.dbo.xp_cmdshell 'dir/s/b G:\FileLibrary'
但这需要大约 4 1/每次加载需要 2 分钟(更何况我还不知道如何获取修改日期)。是的,它是一个网络驱动器,但在本地运行它需要 1 分 16 秒,而且这不是我想要检查的唯一目录。
有没有什么东西可以作为 DLL 或 C# 代码加载到 SQL Server 2005 中,我可以编译这些代码来快速扫描一段时间以来更改的文件(包括夏令时更改)?这些文件存储在 SQL Server 运行的同一台服务器上。
(I looked for an answer, but nothing really solved my issue so far.)
I want to keep a table up to date with a file directory tree within Microsoft SQL Server 2005. I do the norm now:
insert into #resultTable (Path)
exec master.dbo.xp_cmdshell 'dir/s/b G:\FileLibrary'
but this takes about 4 1/2 minutes to load each time (not to mention I don't know how to grab the modified date yet). Yes it's a network drive, but running it locally takes 1 minute 16 seconds, and that's not the only directory I want to check.
Is there something out there I can load in to SQL Server 2005 as a DLL or maybe C# code I can compile to provide a fast scan of files changed since a period in time (including daylight savings changes)? The files are stored on the same server as SQL Server runs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
网上有很多从 SQL Server 内部运行托管代码的示例。 这是一个示例。
这样,您只需让 C# 代码监视目录的更改即可。也许您可以使用这些文章作为起点: 此处和此处。
还有许多其他链接,快速谷歌搜索就会发现。
There are many examples online of running managed code from inside of SQL Server. This is one example.
With that, you just need to have the C# code monitor the directory for changes. Maybe you can use these articles as starting points: Here and Here.
There are many other links too that a quick Google search will uncover.