--判断某个文件夹是否存在
declare @path nvarchar(1000)
set @path='c:\winnt' --c:\windows是要判断的文件夹
create table #t(a int,b int,c int)
insert #t exec master..xp_fileexist @path
if exists(select * from #t where b=1)
begin
select @path+N'存在'
--判断该文件夹是否共享
create table #(re nvarchar(1000))
insert # exec master..xp_cmdshell 'net share'
if exists(select * from # where re like '% '+@path+' %')
select @path+N'已经共享',共享信息=re
from #
where re like '% '+@path+' %'
else
select @path+N'未共享'
drop table #
end
else
select @path+N'不存在'
drop table #t