daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest May 16th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. CREATE TABLE [DIM_TIME](
  3.     TimeID int CONSTRAINT PK_DIM_TIME PRIMARY KEY,
  4.     [Year] int NOT NULL,
  5.     [Month] varchar(10) NOT NULL,
  6.     MonthDay int NOT NULL,
  7.     [Weekday] varchar(10) NOT NULL,
  8.     [Hour] int Not Null
  9. );
  10.  
  11. --Repos
  12. SET DATEFIRST 1;
  13. INSERT INTO [DIM_TIME]
  14. Select distinct r.created as timeid, lefT(r.created, 4) as year, DATENAME(month, cast(cast(left(r.created,8) as varchar(10)) as date)) as month,
  15.         left(right(r.created, 4), 2) as day , DATENAME(dw, cast(cast(left(r.created,8) as varchar(10)) as date)) as dayweek, RIGHT(r.created,2) as hour
  16.         from [FACT_REPOSITORY] as r
  17.         union
  18. Select distinct r.CreationDate as timeid, lefT(r.CreationDate, 4) as year, DATENAME(month, cast(cast(left(r.CreationDate,8) as varchar(10)) as date)) as month,
  19.         left(right(r.CreationDate, 4), 2) as day , DATENAME(dw, cast(cast(left(r.CreationDate,8) as varchar(10)) as date)) as dayweek, RIGHT(r.CreationDate,2) as hour
  20.         from [FACT_QUESTION] as r
  21.         union
  22.         Select distinct r.CreationDate as timeid, lefT(r.CreationDate, 4) as year, DATENAME(month, cast(cast(left(r.CreationDate,8) as varchar(10)) as date)) as month,
  23.         left(right(r.CreationDate, 4), 2) as day , DATENAME(dw, cast(cast(left(r.CreationDate,8) as varchar(10)) as date)) as dayweek, RIGHT(r.CreationDate,2) as hour
  24.         from [FACT_ANSWER] as r
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top