Home Forums SQL Server 7,2000 SQL Server Newbies something better than TRIGGER to send email after table populated with 20 items? RE: something better than TRIGGER to send email after table populated with 20 items?

  • Is there a reason something like this wouldn't work?

    CREATE TRIGGER CheckReportsFinished ON dbo.ReportStatus

    AFTER INSERT

    AS

    DECLARE @COMPLETEDROWS INT = 0

    SELECT @COMPLETEDROWS = COUNT(*) FROM dbo.ReportStatus WHERE [success flag] is not null;

    IF (@COMPLETEDROWS = 20 )

    BEGIN

    -- just an example here

    RAISERROR ('Report Status TRIGGER ACTIVATED.', 16, 1);

    -- you will probably want to use

    -- EXEC msdb.dbo.sp_send_dbmail instead

    -- but this requires configuration before you can use it

    END;

    GO