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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a column constraint

Status
Not open for further replies.

Persmd

Programmer
May 21, 2003
38
0
0
US
Hi,

I have a SQL 2000 database with a table that I'd like to set a constraint on one of the columns, based on data contained in another column.

The column whose data needs to be constrained is a bit type column with a default value of 0. For discussion, I'll call it box_1. The only time I want to allow box_1 to be flipped to a 1 is when the controlling column named car_type contains the value 'F' or 'W'.

Will someone please help me with the expression that I should put in the constraint expression box for the table in question?

Michael
 
Perhaps I didn't ask my question properly, but I did finally figure out the answer.

The expression ended up being:
( box_1 = 1 AND (car_type = 'F' OR car_type = 'W')) OR box_1 = 0




I feel a lot more like I do now...
than I did when I first got here!

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top