Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 CHECK CONSTRAINT

Author  Topic 

Hinduson
Yak Posting Veteran

69 Posts

Posted - 2013-10-17 : 18:10:03
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

38200 Posts

Posted - 2013-10-17 : 19:00:33
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

69 Posts

Posted - 2013-10-17 : 19:01:57
Thanks


Best Regards.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-18 : 03:28:23
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
   

- Advertisement -