如何使用 SQL Server 检查目录是否存在?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13765911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 12:30:49 来源:igfitidea点击:
How do I check if a directory exists using SQL Server?
提问by RJ.
I know this command will create a directory:
我知道这个命令会创建一个目录:
EXEC master.sys.xp_create_subdir 'C:\testing\'
But how do I check whether 'C:\testing\' exists?
但是如何检查 'C:\testing\' 是否存在?
IF EXISTS(...
回答by Shiraz Bhaiji
CREATE TABLE ResultSet (Directory varchar(200))
INSERT INTO ResultSet
EXEC master.dbo.xp_subdirs 'c:\'
Select * FROM ResultSet where Directory = 'testing'
Will return a list of sub directories, you can then check the contents of the list.
会返回一个子目录列表,然后可以查看列表的内容。