I want to send a notification to Slack on Insert into the table. What is the best way to achieve this for a local SQL database? This throws an error Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
USE [MYDB2021]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[mytrigger]
ON [dbo].[Doc_Header ]
AFTER INSERT,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
DECLARE @command VARCHAR(1000)
SET @command = 'C:\notify.bat'
EXEC master..xp_cmdshell @command
END
The Notify.bat file runs a js file to send a notification to slack
@echo OFF
start cmd /k "node C:\slack.js"