/*分时临时表*/ CREATE TABLE #tmpTime ( TimeValue VARCHAR(10) ) /*每小时列表*/ /*8:00-24:00*/ INSERT INTO #tmpTime ( TimeValue ) SELECT RIGHT('00' + CAST(number AS VARCHAR(5)), 2) + ':00' FROM master.dbo.spt_values WHERE type = 'P' AND number BETWEEN 8 AND 24 /*1:00-7:00*/ INSERT INTO #tmpTime ( TimeValue ) SELECT RIGHT('00' + CAST(number AS VARCHAR(5)), 2) + ':00' FROM master.dbo.spt_values WHERE type = 'P' AND number BETWEEN 1 AND 7 /*删除临时表*/ DROP TABLE #tmpTime