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 PandeyRank #642 · 3.7K reputationPosted May 30, 2013, 3:51 AM EDT
i have created a query and checked it , it works properly,
try it.
data inserted==
Pankaj PandeyRank #642 · 3.7K reputationPosted May 30, 2013, 3:44 AM EDT
what the query you are using, share here,
i'll try to correct it.
Bineesh ViswanathRank #1,681 · 907 reputationPosted May 30, 2013, 3:53 AM EDT
AS
classId int not null,
className nvarchar(50) default ' Class1',
Dates datetime,
check(classId between 1 and 5)
Pankaj PandeyRank #642 · 3.7K reputationPosted May 30, 2013, 3:58 AM EDT
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.
Sunny SharmaRank #223 · 11.1K reputationPosted May 30, 2013, 4:01 AM EDT
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.
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jun 1, 2013, 3:05 AM EDT
Your replays are more valuable for me.
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jun 1, 2013, 3:08 AM EDT
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 1, 2013, 10:02 PM EDT