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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count and Condition in SQL Tables

Status
Not open for further replies.

ashishsmith

Programmer
Jun 23, 2004
46
US
I want to count the number of rows from one table and count the number of rows in another table, and then want to compare them to see if the table is getting updated or not?

SELECT (SELECT COUNT(*)
FROM temp_apps_venus_ports) AS Count_1,
(SELECT COUNT(*)
FROM apps_venus_ports) AS Count_2 DECLARE @tempo int DECLARE @final int
SET @tempo = Count_1
SET @final = Count_2 IF (@tempo = @final) PRINT 'Successful' ELSE PRINT 'UnSuccessful'




I have done this much but it's not working, any ideas please......
 
Try this
Code:
DECLARE @tempo int 
DECLARE @final int
SELECT    @tempo = COUNT(*) FROM temp_apps_venus_ports
SELECT    @final = COUNT(*) FROM apps_venus_ports
 IF (@tempo = @final) PRINT 'Successful' ELSE PRINT 'UnSuccessful'

Questions about posting. See faq183-874
 
Thank you very much, it didn't give any mistakes but it didn't print anything anywhere. What i want to do is email myself or popup a message if it is not successful. Do something that when i log on next, i should come to know that transfer was not successful. How should i do that.

Thank you for your reply.
 
If you are importing data, you can set up a DTS package and tell it what action to take if the package is unsuccessful. THere is a net send option to running things on a schedule, to get an email you must have SQL Mail enabled. Or you could just have it send the information to a logging table and check that everytime you log in.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top