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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Trying to add Unique constraint to existing data

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-11-15 : 14:19:32
We have a table and I'm trying to regulate the duplication of one column, since the business rules have now changed. I want to add a composite Unique Constraint Index.

The column I'm looking @ is ActID. We now want to enforce this doesn't get duplicated in conjunction with another column, Work ID.

the layout/schema is the Work ID table(parent) links to the ActID table(child) via the Work ID. What we want to block is any further inserts where duplicate ActID will appear per work ID.

I'm trying to add this to a table, but the constraint fails because the previous business rule allowed the duplication of ActIDs per same WorkID.

I don't see anything via the Properties table where I can ignore existing data.....like the Constraints tab does.

CONSTRAINT [IX_WP_Activities_1] UNIQUE NONCLUSTERED
(
[WorkID],
[ActID]
)
Any ideas are welcome!

Thanks!

X002548
Not Just a Number

15586 Posts

Posted - 2006-11-15 : 15:20:13
No miracles here, you need to eliminate the duplicates first



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-11-15 : 15:23:12
Bret...that's what I thought.

Thanks!
Go to Top of Page
   

- Advertisement -