在SQL Server中如何检测UNC folder 存在
i1999 2015-10-30 02:22:03 DECLARE @File_Exists INT
EXEC Master.dbo.xp_fileexist '\\serverB\SQL_Backup\file.bak', @File_Exists OUT
print @File_Exists
1
And if check folder, can use "nul", but it doesn't work for UNC path
DECLARE @File_Exists INT
EXEC Master.dbo.xp_fileexist '\\serverB\SQL_Backup\nul', @File_Exists OUT
print @File_Exists
0
If use xp_subdirs like:
EXEC master.dbo.xp_subdirs '\\serverB\SQL_Backups'
If the folder doesn't exists,
Msg 22006, Level 16, State 1, Line 3
xp_subdirs could not access '\\ServerB\SQL_Backups\*.*': FindFirstFile() returned error 67, 'The network name cannot be found.'
检测文件都正常,就是检测文件的文件夹就失败或者返回错误结果。