clicker666
IS-IT--Management
Here's a new one. Similar to my last thread, but different. I've made a trigger to tell me when the system is full. Most of the time it works, but when the system is full and a user attempts to login they get an error message on saving to one of the stored procedures related to activity. (Didn't note the name sorry, and I won't put the trigger back in until it's clean)
Also, I've looked around for the syntax for the trigger, and I just can't seem to make it run without the very last line. Anyone know what I am doing wrong in terms of syntax?
Also, I've looked around for the syntax for the trigger, and I just can't seem to make it run without the very last line. Anyone know what I am doing wrong in terms of syntax?
Code:
CREATE TRIGGER SystemFull ON [DYNAMICS].[dbo].[ACTIVITY]
FOR INSERT, UPDATE, DELETE
AS
DECLARE @RECORDS AS INT
DECLARE @r AS INT
SET @RECORDS = (SELECT COUNT (*) FROM [DYNAMICS].[DBO].[ACTIVITY])
IF @RECORDS = 10
EXEC @r = master.dbo.xp_smtp_sendmail
@FROM = N'administrator@mycompany.com',
@TO = N'me@mycompany.com',
@subject = N'Great Plains System Alert - Almost Full',
@message = N'There are currently 10 users in the system.',
@type = N'text/html',
@server = N'127.0.0.1',
@dumpmsg = N'C:\MyEmailLog1.log'
ELSE
IF @RECORDS = 11
EXEC @r = master.dbo.xp_smtp_sendmail
@FROM = N'administrator@mycompany.com',
@TO = N'me@mycompany.com',
@subject = N'Great Plains System Alert - Full',
@message = N'There are currently 11 users in the system.',
@type = N'text/html',
@server = N'127.0.0.1',
@dumpmsg = N'C:\MyEmailLog1.log'
ELSE
set @r = 0