Therefore, in this example the check constraint verifies that a Salary is greater than .00 and less than 0,000.00.When either one of these conditions in the check constraint evaluates to FALSE a row will not be inserted, or updated in the Payroll table, and an error message will be displayed.For instance, say I want to ensure that when I enter an Hourly Salary Type, I want the Salary to be less than 0.00 or when Monthly Salary Type is entered the Salary is not over ,000, and when an Annual Salary Type is enter then any Salary amount is fine.To implement this constraint I could use the following ADD CONSTRAINT clause: Here I have used multiple column conditions together and separated them with an or condition so my check constraint could validate the Salary amount for each of the different Salary Types.This can be done by using the ALTER TABLE statement.
The logical expression may be a single expression like Salary Here I have a CHECK clause that is associated with the Salary column. If you create a column level constraint, you can only refer to the column name in the logical expression of your check constraint.
This check constraint only allows the Salary column to be less than 0,000.00.
When my table is created, this CHECK constraint will be created and given a system generated constraint name (see my article to find out issues associated with system generated constraint names).
There are a number of different processes that can be used to make sure your data validates against your business rules.
Data validate rules can be enforced within your application code in the application layer; or data can be validated by the database engine.