August 15, 2005 at 10:15 pm
Sorry if this is an easy one, but I've just got back from a holiday and my brain hasn't really kicked into gear yet.
I have a table like this
Field1, Field2, Field3
ABC, DEF, 1
GHI, JKL, 0
MNO, PQR, 0
Now I need to apply some sort of constraint or something on the table to ensure that at any given time only one record has field3 set to 1.
Any starters?
--------------------
Colt 45 - the original point and click interface
August 15, 2005 at 10:59 pm
Phil what criteria are you using to set the value of Field3? Is it possible for Field3 to be 0 for all rows or must 1 row always have Field3 = 1?
Mike
August 15, 2005 at 11:38 pm
Only one record in the whole table can be set to 1, all other records must be 0.
At present the field could be edited/updated via Query Analyzer, possibly in the future a ASP.Net webapp.
--------------------
Colt 45 - the original point and click interface
August 16, 2005 at 1:08 am
See this old thread where I provided a solution for the same problem.
August 16, 2005 at 1:57 am
Cool, thanks Chris always love ways to avoid triggers and such
--------------------
Colt 45 - the original point and click interface
August 16, 2005 at 2:02 am
Yes, I am always looking to have declarative constraints, so I think this solution is quite nice but unorthodox I guess.
August 16, 2005 at 10:02 am
Now THAT is clever. Wow.
I wonder what someone would do who came upon that device in an existing database, without knowing what it did :-). Quite a puzzle!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply