﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Check Constraint / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 26 May 2013 00:22:06 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Check Constraint</title><link>http://www.sqlservercentral.com/Forums/Topic682103-338-1.aspx</link><description>You can make qty NOT NULL and you will have consistent behavior.</description><pubDate>Tue, 24 Mar 2009 09:03:06 GMT</pubDate><dc:creator>noeld</dc:creator></item><item><title>RE: Check Constraint</title><link>http://www.sqlservercentral.com/Forums/Topic682103-338-1.aspx</link><description>hellosir,Thanks for ur valuable time and comment......I m more clear now...... thanks a lot for the clarification......I checked by using select * from tab1 where qty&amp;gt;0... and the result was the same as u said...so i m considering it very useful answer from u...Thanks &amp; regards,Mithun Gite</description><pubDate>Tue, 24 Mar 2009 03:13:07 GMT</pubDate><dc:creator>mithun.gite</dc:creator></item><item><title>RE: Check Constraint</title><link>http://www.sqlservercentral.com/Forums/Topic682103-338-1.aspx</link><description>BOL says:"When a row is modified through a view, the WITH CHECK OPTION makes sure the data remains visible through the view after the modification is committed."and"CHECK constraints reject values that evaluate to FALSE. Because null values evaluate to UNKNOWN, their presence in expressions may override a constraint."That explains it - although in both cases there is the same word - CHECK - the action performed is different in each case. WITH CHECK OPTION works the same as if you write a query : SELECT * FROM mytable WHERE col1 &amp;gt; 10 selects rows where (col1 &amp;gt; 10) evaluates to TRUE,  meaning it will not return rows where col1 is NULL, therefore you will not be allowed to enter NULL value into the view. You are allowed to enter rows where CHECK evaluates to TRUE.CHECK constraint prevents entering rows where constraint evaluates to FALSE.[b]Any expression can evaluate to TRUE, FALSE or UNKNOWN. Result of this is that "allow if TRUE" and "not allow if FALSE" is not the same.[/b] If the expression results in NULL, it is neither TRUE nor FALSE, and so a check working with "allow if TRUE" fails, while check working with "not allow if FALSE" succeeds (allows data to be entered).</description><pubDate>Tue, 24 Mar 2009 01:59:03 GMT</pubDate><dc:creator>Vladan</dc:creator></item><item><title>Check Constraint</title><link>http://www.sqlservercentral.com/Forums/Topic682103-338-1.aspx</link><description>Dear Friends,I want one clarification about the Check Constraint....please look into below code create table vv1 (id int identity(1,10),qty numeric(18,2))create view view_vv1asselect * from vv1 WHERE (qty&amp;gt;10) WITH CHECK OPTIONNow when i m trying to insert that below data in view it is giving error.INSERT INTO VIEW_VV1 VALUES (NULL)--GIVES ERROR SAYING THAT NOT ALLOWED AS PER THE CHECK CONSTRAINTNow i am altering my table adding the constraint to the tableALTER TABLE VV1 ADD CONSTRAINT C1 CHECK (QTY&amp;gt;10) --ASSGINING SAME CONSTRAINT IN TABEL NOWNow i m trying to insert the same data as i tried for the view here its allowing..INSERT INTO VV1 VALUES (NULL)--ITS ALLOWING THE INSERTSSo please some one explain me why it like this?Thanks in Advance........Regards,Mithun Gite</description><pubDate>Tue, 24 Mar 2009 00:54:12 GMT</pubDate><dc:creator>mithun.gite</dc:creator></item></channel></rss>