摘自于网络网络:http://blog.csdn.net/wanmdb/article/details/8080636 create table T(日期时间 datetime, 数量 int) insert T union all union all union all union all union all --按日统计 ), 日期时间, ), 数量=sum(数量) from T group by convert(), 日期时间, ) --按周统计 select 日期时间=datepart(
Select GETDATE() as '当前日期',DateName(year,GetDate()) as '年',DateName(month,GetDate()) as '月',DateName(day,GetDate()) as '日',DateName(dw,GetDate()) as '星期',DateName(week,GetDate()) as '周数',DateName(hour,GetDate()) as '时',DateName(minute,GetDate()) as '
通过指定的起始时间,创建该时间段内以年.月.日为时间段的临时表 ALTER PROCEDURE [dbo].[YOUR_SP_Name] -- Add the parameters for the stored procedure here @StartTime DATETIME ,@EndTime DATETIME ASBEGIN -- 将开始时间赋值给临时变量 DECLARE @TempTime DATETIME SET @TempT