I have a database table with a primary key that auto-increments - using MS SQL Server 2000.
However I have another field (standard field) that must not allow duplicates.
Besides writing code to sift through the database every time to check for duplicates (which would take long to search through the db every time), is there any setting in MS SQL Server 2000 that allows for an automatic check for duplication and will prevent duplicates!??
I have everything created, with data already in the table. What I need now is some way to prevent duplicates from occurring.
The Entry_Sheet value needs to be unique. Instead of writing code to run through the entire db each time an insert is performed, is there a simpler way using a SQL Server DB!??
This is the table I'm talking about!
WCD_No needs to be unique!
WM_id is the primary key!
I've created a new index & made WCD_No a unique constraint, however I am still being allowed to enter a duplicate WCD_No! (Using Delphi 7 also!)
I didn't create the table! The person who did create it isn't around! I'm trying to fix it for someone else tho! Can I use the 'alter' statement and make wcd_no unique while it has data in it or do I have to start fresh?
Basically, everything has already been created & the db has loads of info. However WCD_No was never made unique! I need to do this now, but is it possible (without writing loads of code) & will the fact that there are already duplicates in the db for WCD_No affect this?
Server: Msg 1505, Level 16, State 1, Line 1
CREATE UNIQUE INDEX terminated because a duplicate key was found for index ID 39. Most significant primary key is '<NULL>'.
Server: Msg 1750, Level 16, State 1, Line 1
Could not create constraint. See previous errors.
The statement has been terminated.
Is there any way around this or do I have to delete duplicates?
(How do I track ID 39?)