-- Does the file exist?create table #fe (fileexists int, fileasdir int, parent int)insert into #fe exec master..xp_fileexist @pathif exists (select 1 from #fe where fileexists=0) Begin Select @MsgText = 'Scanned Document ' + @path + ' does not exist, scanid=' + CONVERT(Varchar,@imageid) EXECUTE [conv].[WriteToLog] @ModuleName,@procedureName,@MsgText,'C', @RC drop table #fe Return Enddrop table #fe