Prev: I: ODBC error
Next: performance
From: Mahmoud Amin on 15 Apr 2010 05:15 <<but it depends on that column does not have Null or default values.>> Ignore this part of the sentence "Mahmoud Amin" <m_amin33(a)hotmail.com> wrote in message news:e5kiOjH3KHA.1624(a)TK2MSFTNGP06.phx.gbl... > ALTER Table <table_name> > WITH NOCHECK > ADD CONSTRAINT CK_ColumnB > CHECK (ColumnB = ColumnA+1) > > This is will check user input and prevent wrong values but it depends on > that column does not have Null or default values. > > "OceanDeep via SQLMonster.com" <u46587(a)uwe> wrote in message > news:a67cdf403bfbc(a)uwe... >> In SQL 2008 std, I want to default some value in a column based on >> another >> column value within the same table For example, if column A has a value >> of >> 0, then column B can only have a value 1. If column A has a value of 1, >> then >> column B can only have a value of 2. If column A has other values, >> column B >> has 3. Can I use check contraint to do that? If not, what other ways? >> >> OC >> >> -- >> Message posted via SQLMonster.com >> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/201004/1 >> |