June 9, 2014 at 5:11 am
Hi,
I am trying check if a files exists and if so continue with the procedure and if not exit out of the Procedure.
the code I used below but it keeps erroring.
Could any body help.
DECLARE @isExists INT
exec master.dbo.xp_fileexist @temp,
@isExists OUTPUT
SELECT case @isExists
when 1 then 'Yes'
else 'No'
return
end as
June 9, 2014 at 5:22 am
clucasi (6/9/2014)
Hi,I am trying check if a files exists and if so continue with the procedure and if not exit out of the Procedure.
the code I used below but it keeps erroring.
Could any body help.
DECLARE @isExists INT
exec master.dbo.xp_fileexist @temp,
@isExists OUTPUT
SELECT case @isExists
when 1 then 'Yes'
else 'No'
return
end as
Quick questions, what is the error message and where is the declaration for @temp?
😎
June 9, 2014 at 5:26 am
set @temp= 'c:\xxx' + cast(@number as varchar(50)) + '.xml'
DECLARE @isExists INT
exec master.dbo.xp_fileexist @temp,
@isExists OUTPUT
SELECT case @isExists
when 1 then 'Yes'
return
else 'No'
end as isExists
the error is Msg 156, Level 15, State 1, Line 39
Incorrect syntax near the keyword 'return'.
June 9, 2014 at 5:46 am
You need to put your return statement in an IF, not in a SELECT. Example:
IF @isExist = 'No'
RETURN;
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply