June 24, 2009 at 4:56 pm
HI ALL,
I CREATED A TABLE AND APPLIED CHECK CONSTRAINT USING IN AND LATER I AM ENTERING DATA WHY CHECK CONSTRAINT IS ACCEPTING ALL THE INSERT STATEMENTS.
CREATE TABLE TEST1(SNO INT,
NAME VARCHAR(20),
STATUS CHAR(1) CONSTRAINT CHK_1 CHECK (STATUS IN (NULL,'N','Y')) DEFAULT NULL)
INSERT INTO TEST1 VALUES(1,'ABC','')
INSERT INTO TEST1(SNO,NAME) VALUES(1,'ABC')
INSERT INTO TEST1(SNO,NAME,STATUS) VALUES (1,'ABC','T')
THANKS,
SAI
June 24, 2009 at 5:11 pm
PlEaSe HaVe A lOoK tO bOl FoR iN sTaTeMeNt. YoU cAnNoT uSe ThIs FoR nUlL vAlUeS. sO tRy ThIs:
😀
CREATE TABLE TEST1
(
SNO INT,
NAME VARCHAR(20),
STATUS CHAR(1)
CONSTRAINT CHK_1
CHECK (STATUS IS NULL OR STATUS IN ('N','Y'))
DEFAULT NULL
)
INSERT INTO TEST1 VALUES(1,'ABC','')
INSERT INTO TEST1(SNO,NAME) VALUES(1,'ABC')
INSERT INTO TEST1(SNO,NAME,STATUS) VALUES (1,'ABC','T')
SELECT * FROM TEST1
Flo
June 24, 2009 at 6:38 pm
Ow. This thread hurts my eyes and my ears! 😛
June 25, 2009 at 2:36 am
saidwarak01 (6/24/2009)
HI ALL,I CREATED A TABLE AND APPLIED CHECK CONSTRAINT USING IN AND LATER I AM ENTERING DATA WHY CHECK CONSTRAINT IS ACCEPTING ALL THE INSERT STATEMENTS.
Please don't post in all caps. It's the online-equivalent of shouting at someone.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 25, 2009 at 4:12 am
Gail and Paul,
ThAnKs FoR cLaRiFyInG mY pOsT!
June 25, 2009 at 9:30 am
Hi,
My simple advise to moderators is any kind of post whether it is simple or tuff. It should be properly handled by giving some solution. This forum is for helping others with your extra knowledge and extra skills and not to hurt any body by typing CAPS or something else.
Thanks,
sai
June 25, 2009 at 9:50 am
saidwarak01 (6/25/2009)
My simple advise to moderators is any kind of post whether it is simple or tuff. It should be properly handled by giving some solution.
And it has been. See Flo's answer. If that hasn't solved your problem, say so and explain what's missing.
p.s. no moderators have posted in this thread so far.
This forum is for helping others with your extra knowledge and extra skills and not to hurt any body by typing CAPS or something else.
All caps is very hard to read. If a question's hard to read I'm likely to skip it and go elsewhere. You're welcome to post anyway you want, but the harder it is to read and/or answer, the less likely someone is to answer it. Remember we're doing this in our spare time.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 25, 2009 at 9:56 am
sai,
saidwarak01 (6/25/2009)
It should be properly handled by giving some solution.
I gave you a solution. If it doesn't work or you have any questions about let me know.
...and not to hurt any body by typing CAPS or something else.
As Gail wrote, writing in CAPS is like screaming in online-forums.
Flo
June 25, 2009 at 3:00 pm
saidwarak01 (6/25/2009)
My simple advise to moderators is any kind of post whether it is simple or tuff. It should be properly handled by giving some solution. This forum is for helping others with your extra knowledge and extra skills and not to hurt any body by typing CAPS or something else.
If you are unhappy with the posted solution or comments, please accept a full refund with my apologies.
LOL
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply