SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Primary key constraint
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shilpash
Posting Yak Master

103 Posts

Posted - 06/13/2013 :  10:49:48  Show Profile  Reply with Quote
I have a primary key constraint in col a and b in destination.When I was loading it into destination it violates the constraint and the package fail.bUT I really need that data to be inserted as there is a difference in some other column.Is there any other way?

Thank you in advance.

James K
Flowing Fount of Yak Knowledge

3661 Posts

Posted - 06/13/2013 :  12:20:46  Show Profile  Reply with Quote
quote:
Originally posted by shilpash

I have a primary key constraint in col a and b in destination.When I was loading it into destination it violates the constraint and the package fail.bUT I really need that data to be inserted as there is a difference in some other column.Is there any other way?

Thank you in advance.

If there is a primary key constraint on columns a and b, what it is really saying is that no matter what the difference in other columns, the combination of a and b has to be unique.

If you do need non-uniqueness on those columns, that sounds like the business logic is not in sync with the database constraint.

Your only choice is to remove the primary key (uniqueness constraint). You can consider adding additional columns to the primary key constraint to make the combination unique.

When there are no such candidate key columns, people often use surrogate keys - for example an identity column - as the primary key.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 06/14/2013 :  01:42:23  Show Profile  Reply with Quote
You need to be careful on this.
Check the impact first and see which all code are using this table.
When you change primary key there might be lot of dependent code which may get affected as they may rely upon the uniqueness of existing column combination. So these type of changes have to be done carefully after discussing with all involved stakeholders and doing a thorough business impact analysis.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000