SQL Server Performance

ActiveX Script - execute based on record counts

Discussion in 'SQL Server DTS-Related Questions' started by JSal, Apr 12, 2006.

  1. JSal New Member

    Any help would be GREATLY appreciated... I have been scouring the internet to try and do the following:

    Using a DTS package(s), I want to compare the record counts of two tables within the same database: tblCustomer and tblMatches; and based on the Success or Failure result, continue processing. Here is the idea:

    If
    (select count(*) from tblCustomer) = (select count(*) from tblMatches)

    Then
    run the next package according to the "On Success" workflow (or Call by name)

    Else
    Create an error message using an SMTP Mail Task (e.g. - "Error - Record counts do not match")


    Does anyone out there in DTSLand have an idea on how to accomplish this? It will be run locally and in-line with already-established data import, manipulation and export packages.

    Many, many thanks.
    - J

  2. waqar Member

    Hi,

    I have done some thing similar which can give some idea.

    Every day at 2am i check if a flag of a table is 1 then do another procedure else send an email.
    What i did

    1-
    Create a store procedure which do flag check like


    select @flagvar=count(*) from tbl1 where flagfld=1
    if @flgvar=0
    begin
    exec anothersp
    end
    else
    begin
    exec sendemailspwithparameter
    end

    Here <b>anothersp</b> perform some tasks, whereas <b>sendemailspwithparameter</b> accept some parameter and pass those parameter to DTS. This DTS generate an email based on given parameters and send emails to requested user (i was using smtp server to send email, not SQL email option).

    maybe it can give you some idea.

    Regards,
    Waqar.

    ________________________________________________
    ~* Opinions are like a$$holes, everyone got one. *~

Share This Page