I may be the only one who finds this question quite interesting (- just not perfectly explained).
Here is a SQL Fiddle Demo that shows one way of doing this using a cursor to populate the dates. The part of the script I believe you were asking for is shown below:
CREATE TABLE EquipmentLog
([Item Name] varchar(255),
conferencename varchar(255),
[reserved dates] datetime);
DECLARE @Item_Name varchar(255),
@conferencename varchar(255),
@start_reserve_date datetime,
@end_reserve_date datetime,
@reserve_date datetime
DECLARE cur CURSOR FAST_FORWARD
FOR
SELECT * FROM EquipmentRegister
OPEN cur
FETCH NEXT FROM cur
INTO @Item_Name, @conferencename, @start_reserve_date, @end_reserve_date
WHILE (@@FETCH_STATUS=0)
BEGIN
SET @reserve_date = @start_reserve_date
WHILE (@reserve_date <= @end_reserve_date)
BEGIN
INSERT INTO EquipmentLog
SELECT @Item_Name, @conferencename, @reserve_date
SELECT @reserve_date = DATEADD(day, 1, @reserve_date)
END
FETCH NEXT FROM cur
INTO @Item_Name, @conferencename, @start_reserve_date, @end_reserve_date
END
CLOSE cur
DEALLOCATE cur
3
solved How to populate “between dates” given start and end dates