sql - Can a Check constraint relate to another table? -
let´s have 1 table called projecttimespan (which haven´t, example!) containing columns startdate , enddate.
and have table called subprojecttimespan, containing columns called startdate , enddate, set check constraint makes impossible set startdate , enddate values "outside" projecttimespan.startdate projecttimespan.enddate
kind of check constraint knows another tables values...
is possible?
in response comment on gserg's answer, here's example check constraint using function:
alter table yourtable add constraint chk_checkfunction check (dbo.checkfunction() = 1)
where can define function like:
create function dbo.checkfunction() returns int begin return (select 1) end
the function allowed reference other tables.
Comments
Post a Comment