with r AS
( select cast('2020-01-01' as date) lv
union all
select dateadd(dd, 1, lv) from r where dateadd(dd, 1, lv) <= cast('2020-01-31' as date)
) select * from r
;
1~31일까지 출력이 됩니다.
select ts.lv from
(select convert(char(10),dateadd(d,number,'2020-01-01'),120) lv
from master..spt_values
where type = 'P' and number <= datediff(d,'2020-01-01','2020-01-31')
) ts
상위와 동일
'IT > [DB]MsSql' 카테고리의 다른 글
[mssql] Calling a Stored Procedure (0) | 2020.02.13 |
---|---|
[mssql] line number display (0) | 2020.02.13 |
[MSSQL] OPENXML (0) | 2020.01.17 |
[mssql] 이전해 시작일,종료일 구하기 (0) | 2019.12.05 |
[공통] 날짜 재귀출력 (0) | 2019.11.22 |