WITH Date AS ( SELECT CAST('2008-08-01' AS DATETIME) da UNION ALL FROM Date WHERE da < '2008-08-21' ) ) AS c FROM Date ORDER BY da WITH Temp AS ( SELECT 1 [index], REPLACE(NEWID(), '-', '') as guid UNION ALL SELECT [index] + 1, REPLACE(NEWID(), '-',…
要实现的效果:查询从Date From 到 To 之间的 所有日期: 示例代码如下: DECLARE @DATE_FROM DATETIME = N'2016-05-16';--N'2015-05-16';DECLARE @DATE_TO DATETIME = N'2016-05-17';WITH tmpDays AS ( SELECT @DATE_FROM DATE_VALUE UNION ALL …