创建一个包含以下列的表
DateId, Date, Day_Name, Day_of_Week, Day_of_Month, Day_of_Year,
Mon… _Name, Quarter_of_Year, Year_Name,Year
从 2008 年 1 月 1 日到 2014 年 12 月 31 日,写一个查询来填写上表
DECLARE @DATE smalldatetime
DECLARE @DATESTART smalldatetime
DECLARE @DATEEND smalldatetime
SET @DATESTART = '01-01-2008'
SET @DATEEND = '12-31-2014'
--SET @DATE = @DATESTART
DECLARE @days int
DECLARE @index int = 1
SET @days= DATEPART(dayofyear, @DATEEND) - DATEPART(dayofyear, @DATESTART)
SELECT @days
WHILE()
INSERT INTO [BI_Database].[dbo].[Date_
Range]
([Date],[Day_Name],[Day_of_Week],[Day_of…
VALUES(<Date, datetime,>,<Day_Name, nvarchar(50),>,<Day_of_Week, smallint,>,<Day_of_Month, smallint,>,<Day_of_Year, smallint,>,<Month_Name, nvarchar(50),>
,<Month_of_Year, smallint,>,<Quarter_Name, nvarchar(50),>,<Quarter_of_Year, nvarchar(50),>,<Year_Name, nvarchar(50),>,<Year, smallint,>)