能否用sql语句判断某个目录下的某个文件夹是否存在,如果存在则判断它是否共享?
能否用sql语句判断某个目录下的某个文件夹是否存在,如果存在则判断它是否共享? 问题点数:20、回复次数:2Top
1 楼zjcxc(邹建)回复于 2005-02-21 15:32:45 得分 0
--判断目录用
declare @path nvarchar(1000)
set @path='c:\windows' --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)
select @path+N'存在'
else
select @path+N'不存在'
drop table #tTop
2 楼zjcxc(邹建)回复于 2005-02-21 15:37:38 得分 20
--判断某个文件夹是否存在
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
Top




