在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.'

检测文件都正常,就是检测文件的文件夹就失败或者返回错误结果。
...全文
145 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

22,297

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧