New to SQL Please h

mec01

New member
Local time
Yesterday, 22:57
Joined
Feb 13, 2009
Messages
4
:(
Hi Guys
New to SQL coding so can someone please help? I monitoring our replication and would like to take a row count of a table ‘table1’ and match it to the replication table on our tier 2 and 3 environment .
SELECT COUNT(*)AS alais FROM [servername].DB.dbo.Table
SELECT COUNT(*)AS alais FROM [servername].DB.dbo.Table
SELECT COUNT(*)AS alais FROM [servername].DB.dbo.Table
SELECT COUNT(*)AS alais FROM [servername].DB.dbo.Table
SELECT COUNT(*)AS alais FROM [servername].DB.dbo.Table
But I don’t want to receive and email everytime indication everything is ok. Ideally I would like to receive and email\ alert when the row counts do not match.

So How do I compare the resuilt values and then send an email using the IF command?

The one table I am looking at sits on 5 different servers. Sorry bit stuck !!
Also If I wanted to do row counts for mutiple tables accross the servers i.e table1 on all five servers, table 2, table 3 etc.
How could like be done?
Thanks in advance for your help!! :)
 
Where are you stuck? You'd declare 2 variables, set each to the count from a table, compare them and send the email:

If @Table1Count <> @Table@Count
--code to send email here

I use this to send email:

http://sqldev.net/xp/xpsmtp.htm
 
Hi,

Why do you need to do this?

What type of replication are we talking about?

There are built in tools for replication monitoring and if replication starts failing then will start displaying errors and email the dba (configurable).

I just think that if replication is updating records then the row counts wont be the same because it's still updating, so how will your proposed solution deal with that occurance?
 

Users who are viewing this thread

Back
Top Bottom