DECLARE @daysNum INT
DECLARE @currentDay DATETIME
DECLARE @index INT;
DECLARE @NewTable TABLE (
currentDate DATETIME,
realDate DATETIME
)
SET @daysNum = 30
SET @index = 1;
WHILE @index < @daysNum
BEGIN
SET @currentDay = ( SELECT DATEADD(DAY, @index, GETDATE()) )
SET @index = @index + 1
INSERT @NewTable ( currentDate, realDate ) VALUES (CONVERT(VARCHAR(10), @currentDay,112), @currentDay )
END
SELECT * FROM @NewTable
时间: 2024-10-08 22:21:59