I have the following in a email SP:, doing while, i want to check the filepath, if exists then proceed otherwise skip to fetch next. is it possibleFETCH FIRST FROM @hCx INTO @recipient,@copymailto,@Subject,@mailbody,@emailid,@filepathWHILE @@FETCH_STATUS = 0BEGIN IF @recipient is not null BEGIN DELETE tab_ccsnetemailsum WHERE emailid=@emailid IF RIGHT(@filepath, 1) = '\' BEGIN SET @filepath = '' END--Here i want to check if filepath does'nt exist then skip to next. SET @filepath = REPLACE(REPLACE(@filepath,'.doc','.pdf'),'.rtf','.pdf') EXEC msdb.dbo.sp_send_dbmail @profile_name = 'DBMailProfile', @recipients=@recipient, @copy_recipients = @copymailto, @body = @mailbody, @subject=@Subject, @file_attachments=@filepath END FETCH NEXT FROM @hCx INTO @recipient,@copymailto,@Subject,@mailbody,@emailid,@filepath End
Thank you very much for the helpful info.