DECLARE @StartTime DATETIME
DECLARE @EndTime DATETIME
DECLARE @duration INT
--Capture timestamp for start of execution
SET @StartTime = GETDATE()
-- Add the code for your T-SQLscript/ stored procedure
SELECT 'Add the code for your T-SQLscript/ stored procedure'
--Capture timestamp for start of execution
SET @EndTime = GETDATE()
-- Capture the difference in minutes
SET @duration = DATEDIFF(MINUTE, @StartTime, @EndTime)
--Check condition of 5 mins
IF @duration > 5
BEGIN
SELECT 'Sending email mentioning Query execution taking longer than 5 mins'
--Code for sending the email
END
GO
Monday, July 17, 2023
SQL Server - How to get a alert or notification if SQL Query is taking more than 5 mins
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment