Is it possible to query a folder in TSQL, from SQL Management Studio, and return a list of file names? If so, how?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use xp_cmdshell.
Example:
EXECUTE master.dbo.xp_cmdshell 'DIR "C:\YourDirectory\" /A-D /B'
There's a good, full example with more options here.
回答2:
CLR integration is also an option, if you're not comfortable with allowing xp_cmdshell to be executed.
http://msdn.microsoft.com/en-us/library/ms345136%28SQL.90%29.aspx