Domanda

How to map a surrogate key(which is a foreign key to other dimension table) in ssis.

I have Dim.Camp table like this :

Dim.Camp(campkey int identity(1,1),Advkey int,campbk int,campname varchar(10))

Dim.Adv(Advkey int identity(1,1),Advbk int)

The above are my dimension tables,

These are my staging tables:

Camp(Advid int,campid int,campname varchar(10))

Adv(Advid int)

I load my Dim.camp through loop up task in ssis using my staging tables :

Then i get:

Dim.Camp(campkey int identity(1,1),Advkey int,campbk int,campname varchar(10)) populated accept

Advkey which gets all Nulls in its column because there is no corresponding mapping in staging tables

Can somebody tell me what is it I'm doing wrong, ...or how to get this done ?

È stato utile?

Soluzione

I would like to know what is the relationship between the entities or tables "Camp" and "Adv" in your source system or in the staging table. You always need the business key to perform a lookup in the dimension tables, that is, you need the campbk to lookup records in the Dim.Camp and the Advbk to lookup records in the Dime.Camp dimension

If I understood correctly you should load first the Dim.Adv from staging using for instance a merge command in an execute SQL task or in a data flow task. Then you can load the Dim.Camp from Stage, something like this:

Source query:

select Advid as Advbk,campid campbk,campname from Staging.Camp

Then make a lookup (lookup table: Dim.Adv) and get the Dim.Advid where Dim.Adv.Advbk = Advbk

Finally make another lookup (table: Dim.Camp) and then determine if you have to update or insert the records.

Let me know if you have further questions.

Kind Regards,

Paul

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top