标签:sql 日期补全
</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 日期
标签:sql 日期补全
原文地址:http://blog.csdn.net/mssql_dba/article/details/39495683