概述
Declare @BeginDate Datetime
Set @BeginDate='2011-1-1'
While @BeginDate<'2015-12-31'
Begin
Insert Into [InstagramDataDW].[dbo].[Dim_Date]
Select CONVERT(varchar(10),@BeginDate,112) As DateKey,Year(@BeginDate) as Year,
Case When Month(@BeginDate)>6 then 2 Else 1 End As HalfYear,
DATEPART(QUARTER,@BeginDate) As Quarter,
Case When DATEPART(QUARTER,@BeginDate)=1 Then 'one'
When DATEPART(QUARTER,@BeginDate)=2 Then 'two'
When DATEPART(QUARTER,@BeginDate)=3 Then 'three'
Else 'four' End As QuarterEN,
Month(@BeginDate) As Month,
DATEPART(WEEK,@BeginDate) As [WeekOfYear],
DateName(WEEKDAY,@BeginDate) As Week,
Day(@BeginDate) As Day,
CONVERT(varchar(10),@BeginDate,120) As Date
Set @BeginDate=DATEADD(DAY,1,@BeginDate)
End
最后
以上就是结实砖头为你收集整理的数据仓库的时间维度表 Sql的全部内容,希望文章能够帮你解决数据仓库的时间维度表 Sql所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复