Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Overlapped Dates
Message
 
 
To
20/03/2007 16:59:12
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01206271
Message ID:
01206290
Views:
14
>I have a table with transactional records, and each record has a start and an end date. I am creating a SPROC to insert a record into this table, but I want to make sure that the start date and end date in the record I am inserting does not overlap any of the date ranges in any records in the table.
-- @StartDate and @EndDate are dates for new record
IF NOT EXISTS (SELECT * FROM mytable 
		WHERE @StartDate BETWEEN StartDate AND EndDate
			OR @EndDate BETWEEN StartDate AND EndDate)
	INSERT INTO ...
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform