Рет қаралды 659
This video explains how to trigger a SQL deletion trigger and execute a HTTP endpoint using Power Automate.
OLE Automate configuration for SQL
learn.microsoft.com/en-us/sql...
SQL Trigger code. Here Employee is my table.
USE [Employee]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create TRIGGER [dbo].[trgEmployeeDelete]
ON [dbo].[Employee]
FOR DELETE
AS
Declare @varId int;
SELECT @varId = Id FROM DELETED;
declare @Object as Int;
declare @ResponseText as Varchar(8000);
declare @body varchar(max);
set @body='{"Id":' + str(@varId) + '}';
declare @Apilink varchar(max);
set @Apilink='Your Flow https endpoint here';
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'post',@Apilink,'false'
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json'
Exec sp_OAMethod @Object, 'send', null, @body
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT