create table #Exista (Id int, Filepath varchar(512), Exista bit)
insert into #Exista(ID,FilePath)
select Id, replace(FilePath,'/','') from Document where TipDocumentaFK = 16 and DocTemplateFK <>21
create table #Res (ExistaFis bit, EsteDir bit,ExistaParinte bit)
declare @Id int, @filePath varchar(512), @res bit
declare crs cursor for select Id, FilePath from #Exista
open crs
fetch next from crs into @Id, @filePath
while @@fetch_status = 0
begin
set @res = -1
truncate table #Res
insert into #Res exec master..xp_fileexist @filePath
select @res = ExistaFis from #Res
if @res <> - 1
update #Exista set Exista = @res where Id = @Id
fetch next from crs into @Id, @filePath
end
close crs
deallocate crs
select * from #Exista where Exista = 0
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment