SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 CHECK CONSTRAINT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/17/2013 :  18:10:03  Show Profile  Reply with Quote
Please am being asked to Answer this question.

OrderStatus must be any of the following Values: 'In Transit','Received' or 'Cancelled'..

And This is my query Below and I had the Below Error Statement. Please can someone help me with a Better Idea?

ALTER TABLE TRANSACTIONS_ORDERDETAILS
ADD CONSTRAINT myConstraint CHECK(OrderStatus ='InTransit');

Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the CHECK constraint "ckconstraint". The conflict occurred in database "SHOPHERE", table "dbo.TRANSACTIONS_ORDERDETAILS", column 'OrderStatus'.

Best Regards.

tkizer
Almighty SQL Goddess

USA
37135 Posts

Posted - 10/17/2013 :  19:00:33  Show Profile  Visit tkizer's Homepage  Reply with Quote
It's because you already created a check constraint on that column. You can issue an ALTER TABLE DROP CONSTRAINT command to remove it. The one you want to remove is called ckconstraint, according to the error.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/17/2013 :  19:01:57  Show Profile  Reply with Quote
Thanks


Best Regards.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/18/2013 :  03:28:23  Show Profile  Reply with Quote
just as a sidenote
OrderStatus must be any of the following Values: 'In Transit','Received' or 'Cancelled'..
if thats true then check constraint should be like

ALTER TABLE TRANSACTIONS_ORDERDETAILS
ADD CONSTRAINT myConstraint CHECK(OrderStatus IN ('InTransit','Received','Cancelled'));


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000