URGENT- CHECK CONSTRAINT

Database
Enthusiast

URGENT- CHECK CONSTRAINT

Hi, I want to create a table with a column that checks if the value of the column is between 1 and seven. I am using this column to match the value with
system calendar that if today is saturaday and if I have column value 7 then my condition becomes true.

So Plz check if the syntax is ok for CHECK CONSTRAINT.

CREATE TABLE Schema.Table_Name
Process_id AS INT NOT NULL,

Process_day AS INT CHECK (Process_day = 0 || Process_day = 1 || Process_day = 2 || Process_day = 3 || Process_day = 4 || Process_day = 5 || Process_day = 6 || Process_day = 7),

Process_description AS VARCHAR
5 REPLIES
Enthusiast

Re: URGENT- CHECK CONSTRAINT

Or I can use

Process_day AS INT CHECK Between (Process_day = 0) AND (Process_day = 7),
Enthusiast

Re: URGENT- CHECK CONSTRAINT

I mean the following....

Process_day AS INT CHECK (Process_day >= 0 AND Process_day <= 7),

Enthusiast

Re: URGENT- CHECK CONSTRAINT


Process_day INTEGER CHECK (Process_day >= 0 AND Process_day <= 7),

is the correct syntax.

Enthusiast

Re: URGENT- CHECK CONSTRAINT

Your original post mentioned that you wanted it between 1 and 7.

.... you may want to check the conditions on the constraint.
Enthusiast

Re: URGENT- CHECK CONSTRAINT

Thanks Joe,

And Thanks again for following the Thread even those were two seperate Threads.

Yes you are right but in the table definition we want to include ZERO 0 for those entries that we don't want to run. That's why a person can enter Zero to eleminate entries.

Thanks.