Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Notification on query result joining two databases 1

Status
Not open for further replies.

Noonoo

Technical User
Jul 16, 2002
35
GB
Hello.

I have a query which joins tables from 2 databases. If this query returns any records I'd like to send an email notification.

I first thought of using a DTS package but it only seems to be possible to execute a task against one connection and therefore one database at a time.

I also thought of scheduling a bit of vbscript to check this and send the email but can't see a way of doing this against more than one database.

Does anyone have any ideas please?

Thanks.
 
Something like this should do it:

Code:
IF EXISTS (
  SELECT *
  FROM db1..tbl t1 JOIN db2..tbl t2 ON t1.id = t2.id
)
BEGIN
  EXEC master..xp_sendmail 'me@domain.com', 'Data exists!'
END

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top