Use one Execute SQL to get the Max value from DB2, and one to get the Max value from DB1. Store the values in variables, as Jay described. Then have a data flow to do the actual inserts. Have a precendence constraint between the 2 Execute SQL tasks, and one between the 2nd Execute SQL and the data flow. Right-click on the precedence constraint between the 2nd Execute SQL and the data flow task, and change the Evaluation Operation to Expression and Constraint. Leave the Value as Success, and change the Expression to compare the variables you created (something like MaxIDFromDB1 > MaxIDFromDB2). Execution will only flow to the data flow if the expression evaluates to TRUE.
Exec SQL ---> Exec SQL --(expression goes here)-> Data Flow
I think I might be getting what you guys are trying to convey.
So here is what I did.
I added a Sequence Container.
1. I added a Execute Sql Task to it which brings the GenderKey from Prod and puts it in a Variable using the following query ..
SELECT [User::GenderKey_Prod] = ISNULL(MAX(GenderKey) ,0) FROM dbo.DIM_Gender
2. I added another Execute Sql Task which brings the GenderKey from Staging and puts it in another Variable using following query ..
SELECT [User::GenderKey_Stg] = MIN(dg.GenderKey) FROM medical.Fact_Claim mfc
INNER JOIN dbo.Dim_Patient dp ON
dp.PatientKey = mfc.PatientKey
INNER JOIN dbo.Dim_Gender dg ON
dp.GenderKey = dg.GenderKey
WHERE mfc.TaskID =
I added the connector from Prod to Stg (1 -> 2).
3. Then added another data flow task (which will actually transfer the data).
4. And added a connector from STG to this data (2 -> 3) flow task and on this connector I defined the expression check @
[User::GenderKey_Prod] < @ [User::GenderKey_Stg] which if true, will execute the data flow task.
All this makes sense, however, I am having troubles on step 2. Where condition task a parameter called TaskId, this parameter is a
Package Level parameter I have added. I did the parameter mapping, but it keeps giving error on this step says 'Parameter Name is
Unrecognized'. Can you see anything wrong that I have done in Step 2 while defining runtime parameters
Ok, I think I found the issue. The Parameter name in mapping section has to be 0.
But I still have an issue, now the package is running and executing step 1 and 2, after than its just not executing step 3 even if the expression is true. How can i check the values of the variables I assigned value to in step 1 and 2
ASOOD wrote:
SELECT [User::GenderKey_Stg] = MIN(dg.GenderKey) FROM medical.Fact_Claim mfc
INNER JOIN dbo.Dim_Patient dp ON
dp.PatientKey = mfc.PatientKey
INNER JOIN dbo.Dim_Gender dg ON
dp.GenderKey = dg.GenderKey
WHERE mfc.TaskID =
JayH wrote:
You also need to cast the MIN and MAX to avoid and error from SSIS. Those will come back as an object datatype unless you do it like CAST(MIN(dg.GenderKey) AS int).
Phil Brammer wrote:
JayH wrote:
You also need to cast the MIN and MAX to avoid and error from SSIS. Those will come back as an object datatype unless you do it like CAST(MIN(dg.GenderKey) AS int).
I have not had this problem... Can you post a repro
ASOOD wrote:
I was able to debug the values, the prod variables has a value of 0 (it should be 2), I ran the query in Enterprise Manager and it returns 2 so obviously the way i am assigning value in the variable is wrong. I tried casting it, it still always shows 0