I have a MS SQL DB where I need to add a constraint to a filed of a table. This table is manipulated through an application... in a particular field, the integer (field data type) is subtracted from 5 to 4 or 3 whatever, sometimes a user does an error and subracts 3 from 1, then the field becomes -2. I want to have a contraint on the field so there the integer will not go below 0. How can I make that possible??

Thanks

ALTER TABLE TableName
ADD CONSTRAINT
ConstraintName
CHECK
(FieldName >= 0)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.