SSIS Will not load table with Primary Key
I created a package with a Source containing records that are already in my dest tabel. Frrom There I go to lookup records that already exist -----> then conditional split and create two inserts - one for new and one for existing. Existing
records I throw away (multi-cast) then the new records I put in my desitnation.
If I have a PK on the dest table - the new records will not load. Once I took off the PK - the records loaded with no problem.
What is it about the PK that prevents the load?
SQL2K5KDW
November 29th, 2010 4:06pm
It sounds as though you have the logic to determine if the row already exists incorrect. Grab the error output from the ole db destination and put a data viewer on it. Check the records against the destination table to see if there is already
a matching record. Please mark answered posts. Thanks for your time.
Free Windows Admin Tool Kit Click here and download it now
November 29th, 2010 4:11pm
This is the condition in my conditional split ----> ISNULL(lkpUID)
the (lkpUID) is the value returned from the dataflow lookup (my destination)KDW
November 29th, 2010 4:35pm
Have you looked at the records which are producing the errors? Have you compared this against the data that is present in your table? Have you attempted to manually insert these values through T-SQL to see if this produces an error. Etc.
Yes, the logic sounds OK for comparing to see if it is null. But it appears that if you are getting duplicate errors something is not right. Is the key a varchar / char field? If so, are you ensuring that you have them set to the same case
(i.e. uppercase or lowercase) for comparsion?
Hope this helps.Please mark answered posts. Thanks for your time.
Free Windows Admin Tool Kit Click here and download it now
November 29th, 2010 5:05pm
I think I found the problem...
It has to do with a compound PK in the DB. The PK is on both a name and UID -
I am not famliar how to allow for that in SSIS - can you advise?KDW
November 29th, 2010 5:14pm
Just use both of the columns in your lookup. Make sure that you put the source and database into the same case since a lookup in SSIS is case sensitive. Once you get this part hashed out, your logic should be the same...Please mark answered posts. Thanks for your time.
Free Windows Admin Tool Kit Click here and download it now
November 29th, 2010 5:23pm
OK - I've been at this all day -
I have isolated my records coing into my destination as only being new records - It will not insert if the Primary Key is identified on the destination table...
I cant go remove every pk from all the tables i want to load using a ssis package!!KDW
November 29th, 2010 6:01pm
You certainly do not need to remove the PKs from your tables when using SSIS. As I stated, you will need to ensure that the records coming in are in fact new records. Redirect the errors into a flat file or table and look at the values which are giving
the exceptions. Take these values and attempt to insert it by hand through SSMS. Look at any error which is generated from this operation. Make sure that there are not duplicates for the new key in your source data.
If the database is rejecting it, it is already there.Please mark answered posts. Thanks for your time.
Free Windows Admin Tool Kit Click here and download it now
November 29th, 2010 6:24pm
I just rebuilt from scratch - maybe with a little more thought behind the logic - and it works now...
Thanks for your hepKDW
November 29th, 2010 6:45pm