I'm trying to prevent double booking in a booking system, C# to SQL Server.
I'm using stored procedures and tried this:
alter proc Datumkoll
@DatumFrom smalldatetime = null,
@datumTill smalldatetime = null
as
select RumsNummer
from rum
where
RumsNummer not in (select rumsnummer
from rumsbokning
where datumfrån >= @datumfrom and datumtill <= @datumTill)
GO
This code will not prevent double booking if the date is set within an already existing booking