Saturday 15 February 2014

sql server 2008 - select in check constraint -


I want to block a check for my table, where you can not add a new line, if the new booking category ( Start_date, end_date) have perforated each other with a previously submitted row. But I can not keep the query in an obstacle check. You have an idea how it is done

Table:

  Apartman ID INT Price ID booking for INT start dateDate dateEND_DATE DATE at Apartman_id INT [apartman_id] (of Select [id] [db] from [Apartman] where [id] no (choose [apartman_id] [dbo] from [booking] where ([start_date].  = "requested end_date") or (([start_date]  

Instead of the trigger here one that I think handles all the situations.

  Instead of inserting, create dbo.PreventOverlappingBookings trigger on dbo.BOOKINGS as updated, set from start to finish; If present (as selected by 1) I would like to enter internal B (b.id> dbo.BOOKINGS;> i.id or i.id = 0) for inserting - 0 And b.apartman_id = i.apartman_id and ((b.start_date & lt; = i.end_date and b.end_date & gt; = i.start_date) or (b.start_date & lt; = i.start_date and b.end_date & Gt; = i.end_date) or (b.end_date & lt; = i.start_date and b.end_date & gt; = i.end_date))) or exists (- Also make sure to include / update on a set basis To select no overlap in 1 inserted as I inserted on the inner b To get involved, make (b.id   

No comments:

Post a Comment