Dataintegrity between tables in SQL Server -


is possible add data integrity between columns in different tables in sql server? have table pay column date , table orders column dateoforder. , add data integrity date cannot earlier dateoforder. , when user insert there same date or earlier database show error.

i think mean this, here done trigger;

create trigger trig_pay on pay insert, update if exists(select *          [order] o         join inserted         on o.id = i.payment_id         dateoforder>[date]) begin   raiserror ('sorry, dave', 16, 1)   rollback;   return; end  insert [order] values (1, getdate());               -- order today insert pay values (1, dateadd(dd, -1, getdate()));  -- pay yesterday > sorry, dave 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -