Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Oracle sql with "CONNECT BY LEVEL" to T-SQL

Can anyone help to converting following sql to 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);
like image 968
gpa Avatar asked Feb 14 '23 23:02

gpa


1 Answers

This should do the trick, I think

select dateadd(d, number, '2010-12-31') 
from master..spt_values 
where type='p' 
and number between 1 and 2000
like image 138
podiluska Avatar answered Feb 17 '23 19:02

podiluska