SQL Database Mail

Last Post 30 Oct 2008 09:58 AM by JASBRYDEN. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JASBRYDEN
New Member
New Member

--
24 Oct 2008 12:06 PM
Hi

Please help me with this script.

What I want to do is create a little program that would check a file To_BTStandardLoadHeader which is on the database data1, if the importstatus is E, which is an error, then I would like an email send me.

But I script below does not seem to work.
I am using SQL 2005, and I have the database mail setup already.


this part of the script works perfect

USE msdb
GO
EXEC sp_send_dbmail @profile_name='mail beltek',
@recipients='normantang_as@hotmail.com',
@subject='Test message',
@body='TEST'

PLEASE HELP !!!!

use data1
If exists (select * from dbo.To_BTStandardLoadHeader
where importstatus ='E')
else
(USE msdb
GO
EXEC sp_send_dbmail @profile_name='mail beltek',
@recipients='normantang_as@hotmail.com',
@subject='Test message',
@body='TEST')
JASBRYDEN
New Member
New Member

--
30 Oct 2008 09:58 AM
Thanks 'Pro Pete' this was very helpful and it works great !!!!

Thanks again
You are not authorized to post a reply.

Acceptable Use Policy