</pre><pre name="code" class="sql">IF OBJECT_ID('TBL')IS NOT NULL DROP TABLE TBL GO CREATE TABLE TBL( 日期 DATE ) GO INSERT TBL SELECT '2014-09-30' UNION ALL SELECT '2014-10-06' go DECLARE @DATE DATE SELECT @DATE=MAX(日期) FROM TBL ;WITH T AS( SELECT * FROM TBL UNION ALL SELECT DATEADD(DD,1,A.日期) FROM T A WHERE NOT EXISTS(SELECT * FROM TBL B WHERE B.日期=DATEADD(DD,1,A.日期) ) AND A.日期<@DATE ) SELECT *FROM T ORDER BY 日期
时间: 2024-11-05 17:24:47