Validation on Counts

  • Hello everyone,

    I'm new to DTS and I can use some help. There were 2 packages created, both in test and production. What I need to do is compare the total COUNT(*) of records in both packages. If the count is identical in production vs test, then execute the production package. If not identical, then raise an error.

    How would I accomplish this?

    Thanks,

    Peter

    Peter M. Florenzano

    Database Administrator

  • Im not sure if I get it.

    You have two packages that populate two tables. One in test and one in production?

    If thats it then you can use an SQL Query task and add an IF statement in the query that does a count on each table then execute the package.

  • Yes, there are 2 packages that populate 2 tables, one in test and the other in production.

    I wrote the IF statement in the execute SQL task. I'm unsure how to write the query if the counts do indeed match. If they do match, I would like to go to next step. If not, then go to an error log.

    Thanks

    Peter M. Florenzano

    Database Administrator

  • select 1 from table1

    having count(*) = (

    select count(*) from table2 )

    Use an activex task after query read result from global variable then decide what to do

  • IN SQL

    IF EXISTS(select 1 from table1

    having count(*) = (

    select count(*) from table2 ))

    --whatever

    else

    --error

    end

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply