Insert trigger to run an ASPX script passing record columns as parameters

Hello!

I am using SQL Server 2012 and my database is set to 'SQL Server 2000 (80)' compatibility level.

I have a table called "FORMS" and I need that an email be sent every time I get an INSERT in the table.

The email should contains a couple record info including the auto generated key (this is very important). I already have the ASPX script to send the email and I suppose that if this is possible it should be done using a trigger, right?

Could anyone please help me with the details about how to do that?

Thank you!

Hi YanKleber,

You can make a trigger like this on your table:

CREATE TRIGGER dbo.Forms_Insert ON dbo.Forms  
AFTER INSERT  
AS 
 
IF (@@ROWCOUNT  = 0)
RETURN;

DECLARE @key int;
SET @key = (select max(key_column) from inserted);

calling your script here...

GO  

In this case, you need to call your external script.

Used link:
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql?view=sql-server-2017

Regards,
gigawatt38
MCSA: SQL 2016 Database Development
MCSE: Data Management and Analytics