自我创造的表 tRestituiri 是 tImprumuturi
create table tImprumuturi
(
ID_Imprumut int identity primary key,
DataImprumut date default getdate(),
DataScadenta as (dateadd(day,5,DataImprumut)) persisted,
CodCD char(10) foreign key references tCD(CodCd)not null,
CodCV char(10) foreign key references tCaseteVideo(CodCaseta),
CodAb char(10) foreign key references tAbonati(CodAbonat) not null,
CONSTRAINT ucCodCD UNIQUE (CodCD, CodCV),
CONSTRAINT ucCodCV UNIQUE (CodCD, CodAb),
CONSTRAINT ucCodAb UNIQUE (CodCV, CodAb)
)
我希望 tRestituiri 包含以下列:
tRestituiri
(
ID_Restituire int identity primary key,
DataRestituire // it should be equal with DataScadenta from tImprumuturi
CodCD char(10) foreign key references tCD(CodCD),
CodCV char(10) foreign key references tCaseteVido(CodCaseta),
CodAb char(10) foreign key references tAbonati(CodAbonat)
)
但是 tRestituiri 必须仅包含来自 tImprumuturi 的值,其中 DataSccadenta 不早于当前时间 {getdate()}-60 天** *我的意思是来自 tImprumuturi 的值,其中 DataSccadenta 不小于当前时间 -2 个月 *