<var id="xrdpp"><strike id="xrdpp"><listing id="xrdpp"></listing></strike></var>
<cite id="xrdpp"><video id="xrdpp"></video></cite><var id="xrdpp"><video id="xrdpp"><thead id="xrdpp"></thead></video></var>
<cite id="xrdpp"><video id="xrdpp"><menuitem id="xrdpp"></menuitem></video></cite><var id="xrdpp"></var>
<var id="xrdpp"><strike id="xrdpp"><listing id="xrdpp"></listing></strike></var>
<cite id="xrdpp"><video id="xrdpp"><var id="xrdpp"></var></video></cite>
<var id="xrdpp"></var>
<cite id="xrdpp"><video id="xrdpp"></video></cite>
<var id="xrdpp"><video id="xrdpp"><thead id="xrdpp"></thead></video></var>
您現在的位置: 弘智首頁 > .NET > SQL >

SQL點滴5—產生時間demention,主要是時間轉換

時間:2012-10-30 21:57 來源:弘智培訓
數據倉庫中有時間表,存儲時間信息,這個存儲過程接收開始時間結束時間,寫入時間具體信息。有高手用excel函數功能很快能產生INSERT語句不會啊,只能用這個。
參考知識
雙擊代碼全選
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
vSET ANSI_NULLS ON
  GO  
         
  SET QUOTED_IDENTIFIER ON
 GO  
         
 /*--------------------------------------------------------  
 *generate Date demention  
 *@startdate '01/01/2010'
 *@enddate   '12/30/2010'
 ---------------------------------------------------------*/  
         
 CREATE PROCEDURE dbo.AddDateTime  
 @startdate datetime,  
 @enddate datetime  
 AS
   declare @i int
   set @i=1  
           
   while(DATEDIFF(DD,@startdate,@enddate)>=0)  
   begin
           
   insert into [ReportServer].[dbo].[D_DATE](  
     [DATE_KEY],                  --primarykey  
     [DATE],                      --datetime  
     [FULL_DATE_DESCRIPTION],     --detail date  
     [DAY_OF_WEEK],               --day of week from 1 to 6  
     [CALENDAR_MONTH],            --month of year from 1 to 12  
     [CALENDAR_YEAR],             --year  
     [FISCAL_YEAR_MONTH],         --fiscal year  
     [HOLIDAY_INDICATOR],         --holiday iden  
     [WEEKDAY_INDICATOR])  
   select
   @i,  
   CONVERT(varchar(10),@startdate,101),  
   DATENAME(mm,@startdate)+' '+DATENAME(DD,@startdate)+', '+DATENAME(YYYY,@startdate),  
   DATEPART(DW,@startdate),  
   DATEPART(MM,@startdate),   
   DATEPART(YYYY,@startdate),  
   'F'+ CONVERT(varchar(7),@startdate,23),   
   case
   when( CONVERT(varchar(5),@startdate,101) in ('01/01','01/05','02/05','03/05','01/10','02/10','03/10','04/10','05/10','06/10') ) then  1   
   else 0 end,  
   case
   when(DATENAME(DW,@startdate) in ('Saturday','Sunday')) then 1  
   else 0 end
            
   if DATEDIFF(DD,@startdate,@enddate)>=0  
           
   begin
   set @startdate = DATEADD(dd,1,@startdate)  
   set @i=@i+1  
   continue
   end
           
   else
           
   begin
   break  
   end
           
   end
主頁 | 我們介紹 | 我們課程 | 開課公告 | 無錫學歷培訓 | XML地圖
欧美Av无码高清在线_岛国在线无码高清视频_无码国模国产在线观看_第一福利在线永久视频
<var id="xrdpp"><strike id="xrdpp"><listing id="xrdpp"></listing></strike></var>
<cite id="xrdpp"><video id="xrdpp"></video></cite><var id="xrdpp"><video id="xrdpp"><thead id="xrdpp"></thead></video></var>
<cite id="xrdpp"><video id="xrdpp"><menuitem id="xrdpp"></menuitem></video></cite><var id="xrdpp"></var>
<var id="xrdpp"><strike id="xrdpp"><listing id="xrdpp"></listing></strike></var>
<cite id="xrdpp"><video id="xrdpp"><var id="xrdpp"></var></video></cite>
<var id="xrdpp"></var>
<cite id="xrdpp"><video id="xrdpp"></video></cite>
<var id="xrdpp"><video id="xrdpp"><thead id="xrdpp"></thead></video></var>