不支持UNC路径(\\ machine \ share)

时间:2015-04-08 10:16:09

标签: sql sql-server cmd unc

我一直在努力解决以下错误2天ERROR: UNC paths (\\machine\share) are not supported.并且终于遇到了一些有很多上升选票here

海报提到使用pushdpopd映射到免费的驱动器号。但我完全不知道如何做到这一点。而坦率地说,我害怕搞砸了一些事情:(

我将如何实施此pushd& popd到我的SQL代码中:

    DECLARE @N AS VARCHAR(2) -- days for retention
    DECLARE @path AS VARCHAR(128) -- the path for deletion
    DECLARE @cmd AS VARCHAR(512) -- the actual command

    SET @N = '7' -- change the days here (Deleting files which are older that @N days)
    SET @path = '\\TOMANYMS\c$\JohnDoe\91\TEST\serverapps\export' -- Path of the files you would like to check
    SET @cmd = 'FORFILES /P "' + @path + '" /S /M export_status.* /D -' + @N + ' /C "cmd /c del @PATH"' --Deletes on the export_status files older than 7 days.

    EXEC master.dbo.xp_cmdshell @cmd

我认为我需要将其放在我设置@cmd的行中。

任何帮助都会很棒,

非常感谢

1 个答案:

答案 0 :(得分:1)

您可以使用&链接DOS命令。像这样的运算符:

set @cmd = 'pushd '+ @path+  ' & FORFILES /P \ /S /M export_status.* /D -' + @N + ' /C "cmd /c del @PATH"'+' & popd'
相关问题