如何使用 SQL Server 列出文件夹内的文件
问题描述:
如何在不使用 xp_cmdshell
存储过程的情况下列出 SQL Server 中文件夹内的文件?
How do I list files inside a folder in SQL Server without using the xp_cmdshell
stored procedure?
答
您可以使用 xp_dirtree
它需要三个参数:
根目录路径,深度,您希望获取的文件和文件夹以及最后一个用于仅显示文件夹或同时显示文件夹和文件.
Path of a Root Directory, Depth up to which you want to get files and folders and the last one is for showing folders only or both folders and files.
示例:EXEC xp_dirtree 'C:\', 2, 1