1

As it said, I want to add a constraint to a table, and find cannot make Check and Select together.

Here is What I did:

Alter Table table2 Add Constraint chk_table2 Check(Colume21 IN (Select Colume11 From Table 1));

Why does it fail?

Sam
  • 7,252
  • 16
  • 46
  • 65
liudaxingtx
  • 107
  • 10

1 Answers1

1

The documentation says:

The expression of a CHECK constraint may not contain a subquery.

In any case, you cannot use ALTER TABLE to add a constraint later.

However, your constraint looks like a foreign key, which is supported.

CL.
  • 173,858
  • 17
  • 217
  • 259