4

任何人都可以帮助将以下 sql 转换为 T-SQL 吗?

SELECT *
FROM (    SELECT LEVEL n, TO_DATE ('31/12/2010', 'DD/MM/YYYY') + NUMTODSINTERVAL (LEVEL, 'day') CurrDate
          FROM DUAL
    CONNECT BY LEVEL <= 2000);
4

2 回答 2

5

我认为这应该可以解决问题

select dateadd(d, number, '2010-12-31') 
from master..spt_values 
where type='p' 
and number between 1 and 2000
于 2013-10-15T17:15:16.773 回答
3

没关系……找到了……

with n as
(
SELECT TOP (DATEDIFF(DAY, '2010-12-31', '2015-12-31') + 1) 
n = ROW_NUMBER() OVER (ORDER BY [object_id])
FROM sys.all_objects
)
 SELECT DATEADD(DAY, n-1, '2010-12-31')
 FROM n;
于 2013-10-15T17:15:36.030 回答