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
 Other Forums
 Other Topics
 Tricky constraints

Author  Topic 

thread_speaker
Starting Member

1 Post

Posted - 2011-09-29 : 14:21:32
I have a weird situation (or at least it seems unique to me.) I have a table where I have an id, Item, Keyname, and Value. The thing is, I need to be able to have multiple entries with the same value in the Item field, but each of these entries should have a different value in the Keyname.

I can't make Keyname unique though, because if an entry has a different value for Item, it should be allowed to have a Keyname that is also used by a different Item...

Does anyone know how something like this could be done? Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-09-29 : 14:46:23
ALTER TABLE myTable ADD CONSTRAINT UNQ_KeyName_Item UNIQUE(KeyName,Item)
Go to Top of Page
   

- Advertisement -