September 19, 2011 at 4:11 am
I have one table Parent_Table with five columns EmpNo, EmpName, EmpDept, EmpReport. This table contains PK including all EmpNo, EmpName, EmpReport.
And i've one second table as Child_Table with 4 columns Priority, EmpNo, EmpName, EmpReport. It contaisn FK with reference to PK of Parent_Table. But I'm getting duplicate entries in this child_table [as foreign key does not enforce uniqueness]. What should I do so as to check the duplicate records ? There is already an index saying clustered, ignore duplicate keys, unique located on PRIMARY. May be its letting in the duplicate entries irrespective of ignore duplicate keys attribute as it is not unique clustered index ?
September 19, 2011 at 4:23 am
My apologies. It has UNIQUE CLUSTERED INDEX as well with IGNORE_DUP_KEY = ON, on columnsPriority, EmpNo, EmpName, EmpReport. However I want uniqueness for columns EmpNo, EmpName, EmpReport only.
September 19, 2011 at 10:46 am
Pretty hard to interpret what you are saying. I think you are saying you want a 1:1 relationship between the two tables? If so just make your primary key be the three fields and not including the priority. Then you will have a primary and foreign key that are the same.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply