--This runs from PubDB
DECLARE @PubTime datetime, @ReplTime datetime
USE PubDB
SET @PubTime = (select top 1 lastupdate from TABLE1 (NOLOCK) order by lastupdate desc)
/*
The next does the same in the replicated ReplDB via Linked Server.Wouldn't it be it be better here to use OPENQUERY, so I can use the (NOLOCK) hint ?
*/
SET @ReplTime =
(select top 1 lastupdate from [REM_SERVER].[ReplDB].dbo.TABLE1 order by lastupdate desc)
--now the two results will look like that (just an example)
--PubDB
2010-08-21 03:30:000
--ReplDB
2010-08-21 01:30:000
--Now the comparison should follow, and if PubDB minus --ReplDB >90 min. an email should notify [email protected]
IF DATEDIFF(minute, @ReplTime, @PubTime) > 90
EXEC sp_SMTPMail ....
|