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.
| Author |
Topic |
|
Mazdak
Yak Posting Veteran
63 Posts |
Posted - 2002-08-09 : 05:24:38
|
| Whats wrong with this and how can I solve it?<pre>create table checktable1(col1 int not null CONSTRAINT ck_col1 CHECK(col1 between 1 and 100),col2 char(20) CONSTRAINT ck_col2 CHECK (col2 like 'h%'),col3 int not null CONSTRAINT ck_col3 CHECK(col3 >col1))</pre>I got this error:<b>Column CHECK constraint for column 'col3' references another column, table 'checktable1'.</b> |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-09 : 06:38:08
|
| CHECK constraints determine the valid values from a logical expression that is not based on data in another column.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-08-09 : 09:00:07
|
| If you reference other columns in the same table, the constraint must be declared at the table levelcreate table checktable1 (col1 int not null CONSTRAINT ck_col1 CHECK(col1 between 1 and 100), col2 char(20) CONSTRAINT ck_col2 CHECK (col2 like 'h%'), col3 int not null, CONSTRAINT ck_col3 CHECK(col3 >col1)) |
 |
|
|
|
|
|