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!

Help with a package

Status
Not open for further replies.
Dec 31, 2004
71
GB
Hi Everyone,
I am trying to create a package which sends an email if there are values in one table that are not in another, I created a SQL Task as follows;

IF exists (SELECT * FROM table1 WHERE ID not in
(select ID from table2))
begin
PRINT 'NOT OK'
end
ELSE
PRINT 'OK'
However I could not see a way of using a workflow to only send when the output is 'not ok', should I be doing something else

Thanks for all your help
Nathan
 
not sure if ive got this the right way round but you can make the SQL Statement fail by doing something like:
Code:
IF exists (SELECT * FROM table1 WHERE ID not in 
(select ID from table2))
begin
   select * from nonexistenttable
end
ELSE
   PRINT 'OK'

then do a on failure to a email task.

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top