Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

primary key on multiple columns

Status
Not open for further replies.

cruel

Programmer
Aug 6, 2001
131
This is yet the most frustrating thing. I have two columns based on which I want to create a primary key. I have double checked again and again. It absolutely has no duplicate with combined values. But I keep getting an error message saying the second id has duplicates, which should be allowed in this case. Any help?
 
The second id has duplicates?
The message should say that a duplcate jey was found and give the most significant which will be the first entry in the key.

You should create the key by

alter table tbl add constraint PK primary key (col1, col2)

try

select col1, col2
from tbl
group by col1, col2
having count(*) > 1

to check for duplicates.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Thanks, guys. I was looking at two different tables. I am kind of a little paranoid when comes to windows application. It has been a long week already. Happy Thanksgiving!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top