Triggers, Stored Procs and SQL Mail problem

Triggers, Stored Procs and SQL Mail problem

Post by Steve Waldro » Fri, 01 Oct 1999 04:00:00



Hi there,
             can anyone help me with this problem.  I have implemented
triggers on a helpdesk system that runs on SQL Server 6.5 to exec a stored
procedure which in turn, calls xp_sendmail.  This all works fine when you
test it, but on the live system with several users, things start to hang
after a while.  It may be down to my stored procedure or possibly be due to
the Lotus Notes 4.6 (yuk) mail client.  Anyway, here is the stored procedure
that I am calling, is there anything in this that looks suspect?

if exists (select * from sysobjects where id = object_id('dbo.SEND_MAIL')
and sysstat & 0xf = 4)
 drop procedure dbo.SEND_MAIL
GO

CREATE PROCEDURE SEND_MAIL





AS



























 -- Select Call details












 FROM CALL

 -- Select Customer details





 FROM CUSPERS

 -- Select Call Turnaround Time

 FROM SRVTERM

 -- Select Call description

 FROM CALCDESC

 -- Get Call Date/Time




 -- Get Scheduled Close Date/Time









 -- Declare cursor for call notes
 DECLARE CNOTE_LIST CURSOR FOR
  SELECT NOTES FROM CALNOTE

  ORDER BY SRLNO

 -- Remove leading zeros from CALLID


 -- Insert record into temporary table


-- get handle to text field


  FROM MAILTEXT


 BEGIN



CHAR(13)

 END
 ELSE
 BEGIN

CHAR(13)

 END


CHAR(13) +


CHAR(13) +



+











        '[Call Notes]' + SPACE(18) + ':'

 -- Loop round each call note
 OPEN CNOTE_LIST



 BEGIN

CHAR(13)
       FROM CNTNOTES




 END

 CLOSE CNOTE_LIST
 DEALLOCATE CNOTE_LIST


+ CHAR(13) + CHAR(13)



CHAR(13) +



 -- Construct mail query string



 -- Delete temp table entry

GO

 
 
 

1. SQL mail thru Stored Procs ?

Hi,

Is it possible to write a Stored Procedure that will run once in a day and
check in the SQL Server database for certain entries.

And if the condition is satisfied, it has to send a mail.

Is this possible ? If yes, please do guide me.

Actually, what i need to achieve is check whether a user has logged into my
forum in the last 24 hours and if he hasn't then it has to send the user a
reminder about the same. There is a field in the database which has the last
log in time.

So how do i go about it ?

Thanks,
Karthik.

2. Memo field in SQL Server

3. SQL 2000 Problems with stored Procs run from Com via ASP

4. valaran

5. CR no LF problem in SQL server Stored Procs

6. PHP

7. SHAPE problem with Stored Procs in SQL Server

8. How to retrieve the serial value for a new inserted row?

9. Newbie question : arguments of stored procs in triggers

10. Triggers/Stored Procs/Permissions

11. Triggers, Stored Procs and Remote Data

12. Size of triggers and stored-procs

13. Code Coverage Tools for Stored Procs/Triggers?