Sir, I am doing a SQL Query at the moment.
I have a Table named tbl_Class
it have three parameters:- classId(int),className(nvarchar(50),Dates(datetime).
i can't make CHECK Constraint for classId( between 1 and 5) and DEFAULT Constraint for className('FirstClass')
Please Help me.
Loading

Pankaj PandeyPosted May 30, 2013, 7:51 AM
i have created a query and checked it , it works properly,
try it.
data inserted==
Pankaj PandeyPosted Jun 2, 2013, 2:02 AM
Bineesh ViswanathPosted Jun 1, 2013, 7:08 AM
Bineesh ViswanathPosted Jun 1, 2013, 7:05 AM
Your replays are more valuable for me.
Sunny SharmaPosted May 30, 2013, 8:01 AM
As Pankaj has already mentioned the code to create it, use it, it's absolutely fine and works.
If you want to later your table, use the code below:
alter table tbl_Class
add constraint ck_id check (classid>0 and classid<6)
Hope it helps :)
Thanks.
Pankaj PandeyPosted May 30, 2013, 7:58 AM
why you are using procedure when it is possible with table?
anyway, if any other confusion then ask here.
you are using incorrect syntax that i think..may be i am wrong..but my query is working perfactly.
try it and give responce that are you helped with these query otherwise give some detail that what you want exactly and what you done.
Bineesh ViswanathPosted May 30, 2013, 7:53 AM
AS
classId int not null,
className nvarchar(50) default ' Class1',
Dates datetime,
check(classId between 1 and 5)
Pankaj PandeyPosted May 30, 2013, 7:44 AM
what the query you are using, share here,
i'll try to correct it.