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

CHECK constraint help 1

Status
Not open for further replies.

mshields

Programmer
Oct 19, 2002
3
US
I have 2 columns: item_price and item_cost. I need to impose a CHECK constraint at the table level where item_price can never be more than three times the item_cost and also can never be below 120% of the item_cost. Any help would be appreciated.
 
With MS SQL Server I think this will do it.
Code:
ALTER TABLE my_table
ADD CONSTRAINT ck_item_price
CHECK (item_price BETWEEN 1.2 * item_cost AND 3 * item_cost)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top