I have a Minutes table in my database and I want to insert all the minutes in 24hour format (starting from 00:00
) into this table. I can do this using the following query but I am hoping to find a faster query to use instead of this very basic query that I came up with.
DECLARE @Start as Time(0) = CAST('00:00' as time)
DECLARE @ctr int = 0;
WHILE @ctr<>1440
BEGIN
INSERT INTO Minutes(Minute) VALUES(@Start)
SET @Start = DATEADD(minute, 1, @Start)
SET @ctr = @ctr + 1
END
The above query sometimes cause script timeout.