我目前使用它来获取目录/文件名,但需要能够将整体文件夹名称添加到文件名。将文件夹名称添加到文件名与SQL Server
IF OBJECT_ID('tempdb..#DirectoryTree') IS NOT NULL
DROP TABLE #DirectoryTree;
CREATE TABLE #DirectoryTree
(
id INT IDENTITY(1 ,1)
,subdirectory NVARCHAR(512)
,depth INT
,isfile BIT
);
INSERT #DirectoryTree (subdirectory, depth, isfile)
EXEC master.sys.xp_dirtree 'X:\KO Contracts\Contracts', 3, 1;
运行:
SELECT *
FROM #DirectoryTree AS dt
返回:
id subdirectory depth isfile
1 7761601 1 0
2 Documents 2 0
3 12 Month Program.pdf 3 1
4 7764478 1 0
5 Documents 2 0
6 12 Month Program.pdf 3 1
7 7773224 1 0
8 Documents 2 0
9 12 Month Program.pdf 3 1
10 12Month PT.pdf 3 1
11 6 Month Program.pdf 3 1
我需要的是重命名的文件(isfile = 1
)它是(depth = 1
)的目录。
例子:
7761601_12 Month Program.pdf
7764478_12 Month Program.pdf
7773224_12 Month Program.pdf
7773224_12Month PT.pdf
7773224_6 Month Program.pdf
这完美的作品!欣赏它! – Doolius