mutley1
MIS
- Jul 24, 2003
- 909
Hi all,
Running on SQL 2000 SP3a. I have a server configured to email alerts etc. and they all work fine (test mail to operator etc.). I have a job that calls a stored procedure, and all it does is check the time in a lockfile against the system time and will send an email to me if the difference is greater than 15 minutes. This is working fine on our test servers, but live is playing up and gives the following error if it needs to email me (the sp works fine in Analyser and by the job if there is nothing to send. However, if the job falls over with the below message, the Alerter e-mails me (and it comes through!!).
xp_sendmail: failed with mail error 0x80004005 [SQLSTATE 42000] (Error 18025) Associated statement is not prepared [SQLSTATE HY007] (Error 0). The step failed.
Also falls over in QA if it needs to mail me). It's a bit strange because the test server is exactly the same and has no problems. Any help greatly appreciated.
The stored procedure can be seen below.....
CREATE PROCEDURE az_check_despatched_process
AS
DECLARE @mins_runtime int
DECLARE @message VarChar(255)
SET @mins_runtime = (select (DATEDIFF(mi, database..table.start_time, getdate()))
FROM database..table
WHERE database..table.lock = 'despatched')
/*select @mins_runtime*/
IF (@mins_runtime < 15 or @mins_runtime is null) goto end_prog
Select @message = (Select 'Process DESPATCHED has currently been running for '+ CONVERT (char(4),@mins_runtime) + ' minutes
This is longer than the recommended 15 minute threshold. Please investigate.')
EXEC master..xp_sendmail 'jbloggs@mycompany.com',
@message,
@subject = 'WARNING - BCS Process DESPATCHED. Long Runtime.'
end_prog:
GO
Running on SQL 2000 SP3a. I have a server configured to email alerts etc. and they all work fine (test mail to operator etc.). I have a job that calls a stored procedure, and all it does is check the time in a lockfile against the system time and will send an email to me if the difference is greater than 15 minutes. This is working fine on our test servers, but live is playing up and gives the following error if it needs to email me (the sp works fine in Analyser and by the job if there is nothing to send. However, if the job falls over with the below message, the Alerter e-mails me (and it comes through!!).
xp_sendmail: failed with mail error 0x80004005 [SQLSTATE 42000] (Error 18025) Associated statement is not prepared [SQLSTATE HY007] (Error 0). The step failed.
Also falls over in QA if it needs to mail me). It's a bit strange because the test server is exactly the same and has no problems. Any help greatly appreciated.
The stored procedure can be seen below.....
CREATE PROCEDURE az_check_despatched_process
AS
DECLARE @mins_runtime int
DECLARE @message VarChar(255)
SET @mins_runtime = (select (DATEDIFF(mi, database..table.start_time, getdate()))
FROM database..table
WHERE database..table.lock = 'despatched')
/*select @mins_runtime*/
IF (@mins_runtime < 15 or @mins_runtime is null) goto end_prog
Select @message = (Select 'Process DESPATCHED has currently been running for '+ CONVERT (char(4),@mins_runtime) + ' minutes
This is longer than the recommended 15 minute threshold. Please investigate.')
EXEC master..xp_sendmail 'jbloggs@mycompany.com',
@message,
@subject = 'WARNING - BCS Process DESPATCHED. Long Runtime.'
end_prog:
GO