One way to do this is to store both counts in variables. Then, you assign the count value to each variable in each Execute SQL Task
. Finally, you use constraints to check if the variable values are identical and direct flow to the appropriate branch based on the comparison result.
SSIS SQL task to compare to query values
Domanda
SSIS novice needs some help. Not sure if this is possible.
I have a txt file that I am importing into SQL using SSIS. Before I import the file, I do a row count with Powershell and update that value into Database1, Table1, Recordcount So DB1 has:
DB1
FileID RecordCount
1 1500
I can query the count from the table using :
USE Database1
SELECT RecordCount FROM Table1 WHERE (FileID = 1)
//This returns 1500
Next, in SSIS, I import the txt file with a Data Flow task that inserts the data into another database (DB2). The data is then scrubbed, etc.
The FileID field from DB1 matches FileIDRef on DB2
So DB2 has:
DB2
Ref Name Address Zip FileIDRef
1 Jim 11 Lane 33221 1
2 Bill 22 St 77665 1
> ...... .. .....
1500 Jane 44 Rte 23232 1
//etc
I can then run a SQL query to count the rows by FileIDRef:
USE Database2
SELECT COUNT(FileIDRef) AS Expr1 FROM Table1 WHERE (FileIDRef = 1)
Now here is the question. In the very last step of the SSIS, I need to compare FileID against FileIDREF as sometimes the data is corrupt and not all the rows import
If the values of the 2 queries are not equal, branch to a SendMail block to send a warning. If they match, then exit successfully
Can I do this with one SQL statement? Or do I have to set up something in SSIS?
Any help is greatly appreciated!!!
Soluzione