Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to check if filepath exists or not

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-02-04 : 12:17:18
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 possible



FETCH FIRST FROM @hCx INTO @recipient,@copymailto,@Subject,@mailbody,@emailid,@filepath

WHILE @@FETCH_STATUS = 0
BEGIN
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.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:25:00
use xp_fileexist extended sp

http://www.mssqltips.com/tip.asp?tip=1272
Go to Top of Page
   

- Advertisement -