Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-07-09 : 12:03:52
|
| How to inser unique record into a table?Table A has a primary key in MemberID. I used code below but got error said Violation of PRIMARY KEY constraint 'PK_ID'. Cannot insert duplicate key in object 'A'INSERT INTO A(MemberID)SELECT MEMBID FROM B where B.MEMBID not in (select MemberID from A) |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-07-09 : 12:11:07
|
| may be duplicate MEMBID in table B? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-09 : 12:11:47
|
That can only be if table B has more than one record with same ID.In your example DISTINCT would work but I am sure, there are many additional columns in the real world?So your example data isn't clear enough. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|