更新时间:2022-04-14 09:11:05
数字表可以解决您的问题.假设您不需要超过几千行,那么这应该可行:
A numbers table can solve your problem. Assuming you don't need more than a few thousand rows, then this should work:
with n as (
select row_number() over (order by (select null)) - 1 as n
from master.spt_values
)
select d.*,
dateadd(minute, n.n * @intervalMinutes, d.startTime)
from @myDates d join
n
on dateadd(minute, n.n * @intervalMinutes, d.startTime) <= d.endTime;