After changing to
if@exists = 0
begin
raiserror (22004, 'The system cannot find the file specified.')
return2
end
I got the following error:
Msg 102, Level 15, State 1, Procedure sp_SDMS_getfiledetails, Line 34
Incorrect syntax near 'The system cannot find the file specified.'.