IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Discussion :

Gestion de la dimension Temps

  1. #1
    Invité
    Invité(e)
    Par défaut Gestion de la dimension Temps
    Bonjour à tous,

    Je débute en BI et travaille sur un premier projet. Une de mes principales interrogations concerne pour le moment une gestion "propre" des dates. Si j'ai bien compris l'utilité de définir une dimension date contenant toutes les dates de l'intervalle étudié, je suis dans le flou quant à la façon de réaliser ceci.

    Qu'est-il d'usage de faire ?

    1. Gérer ça au niveau de l'import des données avec SSIS ? Dans ce cas, j'imagine la création de la table contenant l'ensemble des dates de la période étudiée, avec des smart keys de type yyyymmdd, et une conversion des dates des tables de fait de leur format original vers le format yyyymmdd pour pouvoir faire le lien.

    2. J'ai aussi remarqué que SSAS permet de générer une dimension Temps, en revanche je cherche toujours comment relier les éléments de cette dimension Temps auto-générée avec des données de ma table de faits (au format datetime par exemple).

    3. D'autres solutions ?


    J'espère avoir été clair, toute aide sera la bienvenue
    D'avance merci,

    PierreAd
    Dernière modification par FrancoisJehl ; 16/01/2012 à 10h12.

  2. #2
    Membre chevronné Avatar de Jinroh77
    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Février 2006
    Messages
    1 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant en Business Intelligence

    Informations forums :
    Inscription : Février 2006
    Messages : 1 964
    Points : 2 145
    Points
    2 145
    Par défaut
    Bonjour,
    Si l'on regarde bien, une très grande partie des données analysées à travers un entrepôt de données tournent autour des dates.
    On regarde le cumulé de la semaine, du mois, une comparaison à la semaine précédente, l'année précédente, on regarde également les ventes en mettant de côté les jours fériés etc.

    Bref, pour tout cela, plutôt que de réaliser de calcul à chaque interrogations afin de retomber sur la bonne date correspondante, ou le bon qualificatif de la date concernée, on crée une table qui va contenir toutes ces informations.

    A ce moment, toutes les interrogations croise cette table sur 1 identifiant simple et performant afin de retrouver l'attribut nécessaire, sans calcul supplémentaire à réaliser.

    Cette table doit donc contenir :
    - 1 identifiant (en général AAAAMMJJ)
    - 1 champ date
    - tous les libellé dont tu auras besoin
    - les numéros et libellé de mois,
    - les identifiants de mois (AAAAMM)
    - les calculs de semaines
    etc...


    Concernant son alimentation, en général cette table est alimentée une bonne fois pour toutes à l'initialisation de l'entrepôt.
    Ce n'est pas ça volumétrie de quelques centaines de milliers de lignes qui changera grand chose
    Alexandre Chemla - Consultant MS BI chez Masao

  3. #3
    Membre averti
    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Juillet 2010
    Messages
    240
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant en Business Intelligence
    Secteur : Conseil

    Informations forums :
    Inscription : Juillet 2010
    Messages : 240
    Points : 359
    Points
    359
    Par défaut
    J'ai publié un article qui aborde un peu le sujet.

    ICI

    En espérant que cela puisse t'aider.

  4. #4
    Membre chevronné

    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Août 2007
    Messages
    1 216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Août 2007
    Messages : 1 216
    Points : 1 758
    Points
    1 758
    Par défaut
    J'ai trouve ce script il y a quelques temps sur la toile (merci a l'auteur ):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
     
    create function [dbo].[F_TABLE_DATE]
    (
    	@FIRST_DATE		datetime,
    	@LAST_DATE		datetime
    )
    /*
    Function: dbo.F_TABLE_DATE
     
    This function returns a date table containing all dates
    from @FIRST_DATE through @LAST_DATE inclusive.
    @FIRST_DATE must be less than or equal to @LAST_DATE.
    The valid date range is 1754-01-01 through 9997-12-31.
    If any input parameters are invalid, the fuction will produce
    an error.
     
    The table returned by F_TABLE_DATE contains a date and
    columns with many calculated attributes of that date.
    It is designed to make it convenient to get various commonly
    needed date attributes without having to program and test
    the same logic in many applications.
     
    F_TABLE_DATE is primarily intended to load a permanant
    date table, but it can be used directly by an application
    when the date range needed falls outside the range loaded
    in a permanant table.
     
    If F_TABLE_DATE is used to load a permanant table, the create
    table code can be copied from this function.  For a permanent
    date table, most columns should be indexed to produce the
    best application performance.
     
     
    Column Descriptions
    ------------------------------------------------------------------
     
     
    DATE_ID               
    	Unique ID = Days since 1753-01-01
     
    DATE                            
    	Date at Midnight(00:00:00.000)
     
    NEXT_DAY_DATE                   
    	Next day after DATE at Midnight(00:00:00.000)
    	Intended to be used in queries against columns
    	containing datetime values (1998-12-13 14:35:16)
    	that need to join to a DATE.
    	Example:
     
    	from
    		MyTable a
    		join
    		DATE b
    		on	a.DateTimeCol >= b. DATE	and
    			a.DateTimeCol < b.NEXT_DAY_DATE
     
    YEAR                            
    	Year number in format YYYY, Example = 2005
     
    YEAR_QUARTER                    
    	Year and Quarter number in format YYYYQ, Example = 20052
     
    YEAR_MONTH                      
    	Year and Month number in format YYYYMM, Example = 200511
     
    YEAR_DAY_OF_YEAR                
    	Year and Day of Year number in format YYYYDDD, Example = 2005364
     
    QUARTER                         
    	Quarter number in format Q, Example = 4
     
    MONTH                           
    	Month number in format MM, Example = 11
     
    DAY_OF_YEAR                     
    	Day of Year number in format DDD, Example = 362
     
    DAY_OF_MONTH                    
    	Day of Month number in format DD, Example = 31
     
    DAY_OF_WEEK                     
    	Day of week number, Sun=1, Mon=2, Tue=3, Wed=4, Thu=5, Fri=6, Sat=7
     
    YEAR_NAME                       
    	Year name text in format YYYY, Example = 2005
     
    YEAR_QUARTER_NAME               
    	Year Quarter name text in format YYYY QQ, Example = 2005 Q3
     
    YEAR_MONTH_NAME                 
    	Year Month name text in format YYYY MMM, Example = 2005 Mar
     
    YEAR_MONTH_NAME_LONG            
    	Year Month long name text in format YYYY MMMMMMMMM,
    	Example = 2005 September
     
    QUARTER_NAME                    
    	Quarter name text in format QQ, Example = Q1
     
    MONTH_NAME                      
    	Month name text in format MMM, Example = Mar
     
    MONTH_NAME_LONG                 
    	Month long name text in format MMMMMMMMM, Example = September
     
    WEEKDAY_NAME                    
    	Weekday name text in format DDD, Example = Tue
     
    WEEKDAY_NAME_LONG               
    	Weekday long name text in format DDDDDDDDD, Example = Wednesday
     
    START_OF_YEAR_DATE              
    	First Day of Year that DATE is in
     
    END_OF_YEAR_DATE                
    	Last Day of Year that DATE is in
     
    START_OF_QUARTER_DATE           
    	First Day of Quarter that DATE is in
     
    END_OF_QUARTER_DATE             
    	Last Day of Quarter that DATE is in
     
    START_OF_MONTH_DATE             
    	First Day of Month that DATE is in
     
    END_OF_MONTH_DATE               
    	Last Day of Month that DATE is in
     
    *** Start and End of week columns allow selections by week
    *** for any week start date needed.
     
    START_OF_WEEK_STARTING_SUN_DATE 
    	First Day of Week starting Sunday that DATE is in
     
    END_OF_WEEK_STARTING_SUN_DATE   
    	Last Day of Week starting Sunday that DATE is in
     
    START_OF_WEEK_STARTING_MON_DATE 
    	First Day of Week starting Monday that DATE is in
     
    END_OF_WEEK_STARTING_MON_DATE   
    	Last Day of Week starting Monday that DATE is in
     
    START_OF_WEEK_STARTING_TUE_DATE 
    	First Day of Week starting Tuesday that DATE is in
     
    END_OF_WEEK_STARTING_TUE_DATE   
    	Last Day of Week starting Tuesday that DATE is in
     
    START_OF_WEEK_STARTING_WED_DATE 
    	First Day of Week starting Wednesday that DATE is in
     
    END_OF_WEEK_STARTING_WED_DATE   
    	Last Day of Week starting Wednesday that DATE is in
     
    START_OF_WEEK_STARTING_THU_DATE 
    	First Day of Week starting Thursday that DATE is in
     
    END_OF_WEEK_STARTING_THU_DATE   
    	Last Day of Week starting Thursday that DATE is in
     
    START_OF_WEEK_STARTING_FRI_DATE 
    	First Day of Week starting Friday that DATE is in
     
    END_OF_WEEK_STARTING_FRI_DATE   
    	Last Day of Week starting Friday that DATE is in
     
    START_OF_WEEK_STARTING_SAT_DATE 
    	First Day of Week starting Saturday that DATE is in
     
    END_OF_WEEK_STARTING_SAT_DATE   
    	Last Day of Week starting Saturday that DATE is in
     
    *** Sequence No columns are intended to allow easy offsets by
    *** Quarter, Month, or Week for applications that need to look at
    *** Last or Next Quarter, Month, or Week.  Thay can also be used to
    *** generate dynamic cross tab results by Quarter, Month, or Week.
     
    QUARTER_SEQ_NO                  
    	Sequential Quarter number as offset from Quarter starting 1753/01/01
     
    MONTH_SEQ_NO                    
    	Sequential Month number as offset from Month starting 1753/01/01
     
    WEEK_STARTING_SUN_SEQ_NO        
    	Sequential Week number as offset from Week starting Sunday, 1753/01/07
     
    WEEK_STARTING_MON_SEQ_NO        
    	Sequential Week number as offset from Week starting Monday, 1753/01/01
     
    WEEK_STARTING_TUE_SEQ_NO        
    	Sequential Week number as offset from Week starting Tuesday, 1753/01/02
     
    WEEK_STARTING_WED_SEQ_NO        
    	Sequential Week number as offset from Week starting Wednesday, 1753/01/03
     
    WEEK_STARTING_THU_SEQ_NO        
    	Sequential Week number as offset from Week starting Thursday, 1753/01/04
     
    WEEK_STARTING_FRI_SEQ_NO        
    	Sequential Week number as offset from Week starting Friday, 1753/01/05
     
    WEEK_STARTING_SAT_SEQ_NO        
    	Sequential Week number as offset from Week starting Saturday, 1753/01/06
     
    JULIAN_DATE                     
    	Julian Date number as offset from noon on January 1, 4713 BCE
    	to noon on day of DATE in system of Joseph Scaliger
     
    MODIFIED_JULIAN_DATE            
    	Modified Julian Date number as offset from midnight(00:00:00.000) on
    	1858/11/17 to midnight(00:00:00.000) on day of DATE
     
    ISO_DATE                        
    	ISO 8601 Date in format YYYY-MM-DD, Example = 2004-02-29
     
    ISO_YEAR_WEEK_NO                
    	ISO 8601 year and week in format YYYYWW, Example = 200403
     
    ISO_WEEK_NO                     
    	ISO 8601 week of year in format WW, Example = 52
     
    ISO_DAY_OF_WEEK                 
    	ISO 8601 Day of week number, 
    	Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6, Sun=7
     
    ISO_YEAR_WEEK_NAME              
    	ISO 8601 year and week in format YYYY-WNN, Example = 2004-W52
     
    ISO_YEAR_WEEK_DAY_OF_WEEK_NAME  
    	ISO 8601 year, week, and day of week in format YYYY-WNN-D,
    	Example = 2004-W52-2
     
    DATE_FORMAT_YYYY_MM_DD          
    	Text date in format YYYY/MM/DD, Example = 2004/02/29
     
    DATE_FORMAT_YYYY_M_D            
    	Text date in format YYYY/M/D, Example = 2004/2/9
     
    DATE_FORMAT_MM_DD_YYYY          
    	Text date in format MM/DD/YYYY, Example = 06/05/2004
     
    DATE_FORMAT_M_D_YYYY            
    	Text date in format M/D/YYYY, Example = 6/5/2004
     
    DATE_FORMAT_MMM_D_YYYY          
    	Text date in format MMM D, YYYY, Example = Jan 4, 2006
     
    DATE_FORMAT_MMMMMMMMM_D_YYYY    
    	Text date in format MMMMMMMMM D, YYYY, Example = September 3, 2004
     
    DATE_FORMAT_MM_DD_YY            
    	Text date in format MM/DD/YY, Example = 06/05/97
     
    DATE_FORMAT_M_D_YY              
    	Text date in format M/D/YY, Example = 6/5/97
     
    */
     
    returns  @DATE table 
    (
    [DATE_ID]				[int]		not null 
    	primary key clustered,
    [DATE]					[datetime]	not null ,
    [NEXT_DAY_DATE]				[datetime]	not null ,
    [YEAR]					[smallint]	not null ,
    [YEAR_QUARTER]				[int]	not null ,
    [YEAR_MONTH]				[int]		not null ,
    [YEAR_DAY_OF_YEAR]			[int]		not null ,
    [QUARTER]				[tinyint]	not null ,
    [MONTH]					[tinyint]	not null ,
    [DAY_OF_YEAR]				[smallint]	not null ,
    [DAY_OF_MONTH]				[smallint]	not null ,
    [DAY_OF_WEEK]				[tinyint]	not null ,
     
    [YEAR_NAME]				[varchar] (4)	not null ,
    [YEAR_QUARTER_NAME]			[varchar] (7)	not null ,
    [YEAR_MONTH_NAME]			[varchar] (8)	not null ,
    [YEAR_MONTH_NAME_LONG]			[varchar] (14)	not null ,
    [QUARTER_NAME]				[varchar] (2)	not null ,
    [MONTH_NAME]				[varchar] (3)	not null ,
    [MONTH_NAME_LONG]			[varchar] (9)	not null ,
    [WEEKDAY_NAME]				[varchar] (3)	not null ,
    [WEEKDAY_NAME_LONG]			[varchar] (9)	not null ,
     
    [START_OF_YEAR_DATE]			[datetime]	not null ,
    [END_OF_YEAR_DATE]			[datetime]	not null ,
    [START_OF_QUARTER_DATE]			[datetime]	not null ,
    [END_OF_QUARTER_DATE]			[datetime]	not null ,
    [START_OF_MONTH_DATE]			[datetime]	not null ,
    [END_OF_MONTH_DATE]			[datetime]	not null ,
     
    [START_OF_WEEK_STARTING_SUN_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_SUN_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_MON_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_MON_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_TUE_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_TUE_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_WED_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_WED_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_THU_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_THU_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_FRI_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_FRI_DATE]		[datetime]	not null ,
    [START_OF_WEEK_STARTING_SAT_DATE]	[datetime]	not null ,
    [END_OF_WEEK_STARTING_SAT_DATE]		[datetime]	not null ,
     
    [QUARTER_SEQ_NO]			[int]		not null ,
    [MONTH_SEQ_NO]				[int]		not null ,
     
    [WEEK_STARTING_SUN_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_MON_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_TUE_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_WED_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_THU_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_FRI_SEQ_NO]		[int]		not null ,
    [WEEK_STARTING_SAT_SEQ_NO]		[int]		not null ,
     
    [JULIAN_DATE]				[int]		not null ,
    [MODIFIED_JULIAN_DATE]			[int]		not null ,
     
    [ISO_DATE]				[varchar](10)	not null ,
    [ISO_YEAR_WEEK_NO]			[int]		not null ,
    [ISO_WEEK_NO]				[smallint]	not null ,
    [ISO_DAY_OF_WEEK]			[tinyint]	not null ,
    [ISO_YEAR_WEEK_NAME]			[varchar](8)	not null ,
    [ISO_YEAR_WEEK_DAY_OF_WEEK_NAME]	[varchar](10)	not null ,
     
    [DATE_FORMAT_YYYY_MM_DD]		[varchar](10)	not null ,
    [DATE_FORMAT_YYYY_M_D]			[varchar](10)	not null ,
    [DATE_FORMAT_MM_DD_YYYY]		[varchar](10)	not null ,
    [DATE_FORMAT_M_D_YYYY]			[varchar](10)	not null ,
    [DATE_FORMAT_MMM_D_YYYY]		[varchar](12)	not null ,
    [DATE_FORMAT_MMMMMMMMM_D_YYYY]		[varchar](18)	not null ,
    [DATE_FORMAT_MM_DD_YY]			[varchar](8)	not null ,
    [DATE_FORMAT_M_D_YY]			[varchar](8)	not null 
    ) 
    as
    begin
    declare @cr			varchar(2)
    select @cr			= char(13)+Char(10)
    declare @ErrorMessage		varchar(400)
    declare @START_DATE		datetime
    declare @END_DATE		datetime
    declare @LOW_DATE	datetime
     
    declare	@start_no	int
    declare	@end_no	int
     
    -- Verify @FIRST_DATE is not null 
    if @FIRST_DATE is null
    	begin
    	select @ErrorMessage =
    		'@FIRST_DATE cannot be null'
    	goto Error_Exit
    	end
     
    -- Verify @LAST_DATE is not null 
    if @LAST_DATE is null
    	begin
    	select @ErrorMessage =
    		'@LAST_DATE cannot be null'
    	goto Error_Exit
    	end
     
    -- Verify @FIRST_DATE is not before 1754-01-01
    IF  @FIRST_DATE < '17540101'	begin
    	select @ErrorMessage =
    		'@FIRST_DATE cannot before 1754-01-01'+
    		', @FIRST_DATE = '+
    		isnull(convert(varchar(40),@FIRST_DATE,121),'NULL')
    	goto Error_Exit
    	end
     
    -- Verify @LAST_DATE is not after 9997-12-31
    IF  @LAST_DATE > '99971231'	begin
    	select @ErrorMessage =
    		'@LAST_DATE cannot be after 9997-12-31'+
    		', @LAST_DATE = '+
    		isnull(convert(varchar(40),@LAST_DATE,121),'NULL')
    	goto Error_Exit
    	end
     
    -- Verify @FIRST_DATE is not after @LAST_DATE
    if @FIRST_DATE > @LAST_DATE
    	begin
    	select @ErrorMessage =
    		'@FIRST_DATE cannot be after @LAST_DATE'+
    		', @FIRST_DATE = '+
    		isnull(convert(varchar(40),@FIRST_DATE,121),'NULL')+
    		', @LAST_DATE = '+
    		isnull(convert(varchar(40),@LAST_DATE,121),'NULL')
    	goto Error_Exit
    	end
     
    -- Set @START_DATE = @FIRST_DATE at midnight
    select @START_DATE	= dateadd(dd,datediff(dd,0,@FIRST_DATE),0)
    -- Set @END_DATE = @LAST_DATE at midnight
    select @END_DATE	= dateadd(dd,datediff(dd,0,@LAST_DATE),0)
    -- Set @LOW_DATE = earliest possible SQL Server datetime
    select @LOW_DATE	= convert(datetime,'17530101')
     
    -- Find the number of day from 1753-01-01 to @START_DATE and @END_DATE
    select	@start_no	= datediff(dd,@LOW_DATE,@START_DATE) ,
    	@end_no	= datediff(dd,@LOW_DATE,@END_DATE)
     
    -- Declare number tables
    declare @num1 table (NUMBER int not null primary key clustered)
    declare @num2 table (NUMBER int not null primary key clustered)
    declare @num3 table (NUMBER int not null primary key clustered)
     
    -- Declare table of ISO Week ranges
    declare @ISO_WEEK table
    (
    [ISO_WEEK_YEAR] 		int		not null
    	primary key clustered,
    [ISO_WEEK_YEAR_START_DATE]	datetime	not null,
    [ISO_WEEK_YEAR_END_DATE]	Datetime	not null
    )
     
    -- Find rows needed in number tables
    declare	@rows_needed		int
    declare	@rows_needed_root	int
    select	@rows_needed		= @end_no - @start_no + 1
    select  @rows_needed		=
    		case
    		when @rows_needed < 10
    		then 10
    		else @rows_needed
    		end
    select	@rows_needed_root	= convert(int,ceiling(sqrt(@rows_needed)))
     
    -- Load number 0 to 16
    insert into @num1 (NUMBER)
    select NUMBER = 0 union all select  1 union all select  2 union all
    select          3 union all select  4 union all select  5 union all
    select          6 union all select  7 union all select  8 union all
    select          9 union all select 10 union all select 11 union all
    select         12 union all select 13 union all select 14 union all
    select         15
    order by
    	1
    -- Load table with numbers zero thru square root of the number of rows needed +1
    insert into @num2 (NUMBER)
    select
    	NUMBER = a.NUMBER+(16*b.NUMBER)+(256*c.NUMBER)
    from
    	@num1 a cross join @num1 b cross join @num1 c
    where
    	a.NUMBER+(16*b.NUMBER)+(256*c.NUMBER) <
    	@rows_needed_root
    order by
    	1
     
    -- Load table with the number of rows needed for the date range
    insert into @num3 (NUMBER)
    select
    	NUMBER = a.NUMBER+(@rows_needed_root*b.NUMBER)
    from
    	@num2 a
    	cross join
    	@num2 b
    where
    	a.NUMBER+(@rows_needed_root*b.NUMBER) < @rows_needed
    order by
    	1
     
    declare	@iso_start_year	int
    declare	@iso_end_year	int
     
    select	@iso_start_year	= datepart(year,dateadd(year,-1,@start_date))
    select	@iso_end_year	= datepart(year,dateadd(year,1,@end_date))
     
    -- Load table with start and end dates for ISO week years
    insert into @ISO_WEEK
    	(
    	[ISO_WEEK_YEAR],
    	[ISO_WEEK_YEAR_START_DATE],
    	[ISO_WEEK_YEAR_END_DATE]
    	)
    select
    	[ISO_WEEK_YEAR] = a.NUMBER,
    	[0ISO_WEEK_YEAR_START_DATE]	=
    		dateadd(dd,(datediff(dd,@LOW_DATE,
    		dateadd(day,3,dateadd(year,a.[NUMBER]-1900,0))
    		)/7)*7,@LOW_DATE),
    	[ISO_WEEK_YEAR_END_DATE]	=
    		dateadd(dd,-1,dateadd(dd,(datediff(dd,@LOW_DATE,
    		dateadd(day,3,dateadd(year,a.[NUMBER]+1-1900,0))
    		)/7)*7,@LOW_DATE))
    from
    	(
    	select
    		NUMBER = NUMBER+@iso_start_year
    	from
    		@num3
    	where
    		NUMBER+@iso_start_year <= @iso_end_year
    	) a
    order by
    	a.NUMBER
     
    -- Load Date table
    insert into @DATE
    select
    	[DATE_ID]			= a.[DATE_ID] ,
    	[DATE]				= a.[DATE] ,
     
    	[NEXT_DAY_DATE]			=
    		dateadd(day,1,a.[DATE]) ,
     
    	[YEAR]			=
    		datepart(year,a.[DATE]) ,
    	[YEAR_QUARTER]		=
    		(10*datepart(year,a.[DATE]))+datepart(quarter,a.[DATE]) ,
     
    	[YEAR_MONTH]		=
    		(100*datepart(year,a.[DATE]))+datepart(month,a.[DATE]) ,
    	[YEAR_DAY_OF_YEAR]		=
    		(1000*datepart(year,a.[DATE]))+
    		datediff(dd,dateadd(yy,datediff(yy,0,a.[DATE]),0),a.[DATE])+1 ,
    	[QUARTER]		=
    		datepart(quarter,a.[DATE]) ,
    	[MONTH]		=
    		datepart(month,a.[DATE]) ,
    	[DAY_OF_YEAR]			=
    		datediff(dd,dateadd(yy,datediff(yy,0,a.[DATE]),0),a.[DATE])+1 ,
    	[DAY_OF_MONTH]			=
    		datepart(day,a.[DATE]) ,
    	[DAY_OF_WEEK]		=
    		-- Sunday = 1, Monday = 2, ,,,Saturday = 7
    		(datediff(dd,'17530107',a.[DATE])%7)+1  ,
    	[YEAR_NAME]		=
    		datename(year,a.[DATE]) ,
    	[YEAR_QUARTER_NAME]	=
    		datename(year,a.[DATE])+' Q'+datename(quarter,a.[DATE]) ,
    	[YEAR_MONTH_NAME]	=
    		datename(year,a.[DATE])+' '+left(datename(month,a.[DATE]),3) ,
    	[YEAR_MONTH_NAME_LONG]	=
    		datename(year,a.[DATE])+' '+datename(month,a.[DATE]) ,
    	[QUARTER_NAME]		=
    		'Q'+datename(quarter,a.[DATE]) ,
    	[MONTH_NAME]		=
    		left(datename(month,a.[DATE]),3) ,
    	[MONTH_NAME_LONG]	=
    		datename(month,a.[DATE]) ,
    	[WEEKDAY_NAME]		=
    		left(datename(weekday,a.[DATE]),3) ,
    	[WEEKDAY_NAME_LONG]	=
    		datename(weekday,a.[DATE]),
     
    	[START_OF_YEAR_DATE]	=
    		dateadd(year,datediff(year,0,a.[DATE]),0) ,
    	[END_OF_YEAR_DATE]	=
    		dateadd(day,-1,dateadd(year,datediff(year,0,a.[DATE])+1,0)) ,
     
    	[START_OF_QUARTER_DATE]	=
    		dateadd(quarter,datediff(quarter,0,a.[DATE]),0) ,
    	[END_OF_QUARTER_DATE]	=
    		dateadd(day,-1,dateadd(quarter,datediff(quarter,0,a.[DATE])+1,0)) ,
     
    	[START_OF_MONTH_DATE]	=
    		dateadd(month,datediff(month,0,a.[DATE]),0) ,
    	[END_OF_MONTH_DATE]	=
    		dateadd(day,-1,dateadd(month,datediff(month,0,a.[DATE])+1,0)),
     
    	[START_OF_WEEK_STARTING_SUN_DATE]	=
    		dateadd(dd,(datediff(dd,'17530107',a.[DATE])/7)*7,'17530107'),
    	[END_OF_WEEK_STARTING_SUN_DATE]		=
    		dateadd(dd,((datediff(dd,'17530107',a.[DATE])/7)*7)+6,'17530107'),
     
    	[START_OF_WEEK_STARTING_MON_DATE]	=
    		dateadd(dd,(datediff(dd,'17530101',a.[DATE])/7)*7,'17530101'),
    	[END_OF_WEEK_STARTING_MON_DATE]		=
    		dateadd(dd,((datediff(dd,'17530101',a.[DATE])/7)*7)+6,'17530101'),
     
    	[START_OF_WEEK_STARTING_TUE_DATE]	=
    		dateadd(dd,(datediff(dd,'17530102',a.[DATE])/7)*7,'17530102'),
    	[END_OF_WEEK_STARTING_TUE_DATE]		=
    		dateadd(dd,((datediff(dd,'17530102',a.[DATE])/7)*7)+6,'17530102'),
     
    	[START_OF_WEEK_STARTING_WED_DATE]	=
    		dateadd(dd,(datediff(dd,'17530103',a.[DATE])/7)*7,'17530103'),
    	[END_OF_WEEK_STARTING_WED_DATE]		=
    		dateadd(dd,((datediff(dd,'17530103',a.[DATE])/7)*7)+6,'17530103'),
     
    	[START_OF_WEEK_STARTING_THU_DATE]	=
    		dateadd(dd,(datediff(dd,'17530104',a.[DATE])/7)*7,'17530104'),
    	[END_OF_WEEK_STARTING_THU_DATE]		=
    		dateadd(dd,((datediff(dd,'17530104',a.[DATE])/7)*7)+6,'17530104'),
     
    	[START_OF_WEEK_STARTING_FRI_DATE]	=
    		dateadd(dd,(datediff(dd,'17530105',a.[DATE])/7)*7,'17530105'),
    	[END_OF_WEEK_STARTING_FRI_DATE]		=
    		dateadd(dd,((datediff(dd,'17530105',a.[DATE])/7)*7)+6,'17530105'),
     
    	[START_OF_WEEK_STARTING_SAT_DATE]	=
    		dateadd(dd,(datediff(dd,'17530106',a.[DATE])/7)*7,'17530106'),
    	[END_OF_WEEK_STARTING_SAT_DATE]		=
    		dateadd(dd,((datediff(dd,'17530106',a.[DATE])/7)*7)+6,'17530106'),
     
    	[QUARTER_SEQ_NO]			= 
    		datediff(quarter,@LOW_DATE,a.[DATE]),
    	[MONTH_SEQ_NO]				=
    		datediff(month,@LOW_DATE,a.[DATE]),
     
    	[WEEK_STARTING_SUN_SEQ_NO]		=
    		datediff(day,'17530107',a.[DATE])/7,
    	[WEEK_STARTING_MON_SEQ_NO]		=
    		datediff(day,'17530101',a.[DATE])/7,
    	[WEEK_STARTING_TUE_SEQ_NO]		=
    		datediff(day,'17530102',a.[DATE])/7,
    	[WEEK_STARTING_WED_SEQ_NO]		=
    		datediff(day,'17530103',a.[DATE])/7,
    	[WEEK_STARTING_THU_SEQ_NO]		=
    		datediff(day,'17530104',a.[DATE])/7,
    	[WEEK_STARTING_FRI_SEQ_NO]		=
    		datediff(day,'17530105',a.[DATE])/7,
    	[WEEK_STARTING_SAT_SEQ_NO]		=
    		datediff(day,'17530106',a.[DATE])/7,
     
    	[JULIAN_DATE]			=
    		datediff(day,@LOW_DATE,a.[DATE])+2361331,
    	[MODIFIED_JULIAN_DATE]		=
    		datediff(day,'18581117',a.[DATE]),
    --/*
     
    	[ISO_DATE]		=
    		replace(convert(char(10),a.[DATE],111),'/','-') ,
     
    	[ISO_YEAR_WEEK_NO]		=
    		(100*b.[ISO_WEEK_YEAR])+
    		(datediff(dd,b.[ISO_WEEK_YEAR_START_DATE],a.[DATE])/7)+1 ,
     
    	[ISO_WEEK_NO]		=
    		(datediff(dd,b.[ISO_WEEK_YEAR_START_DATE],a.[DATE])/7)+1 ,
     
    	[ISO_DAY_OF_WEEK]		=
    		-- Sunday = 1, Monday = 2, ,,,Saturday = 7
    		(datediff(dd,@LOW_DATE,a.[DATE])%7)+1  ,
     
    	[ISO_YEAR_WEEK_NAME]		=
    		convert(varchar(4),b.[ISO_WEEK_YEAR])+'-W'+
    		right('00'+convert(varchar(2),(datediff(dd,b.[ISO_WEEK_YEAR_START_DATE],a.[DATE])/7)+1),2) ,
     
    	[ISO_YEAR_WEEK_DAY_OF_WEEK_NAME]		=
    		convert(varchar(4),b.[ISO_WEEK_YEAR])+'-W'+
    		right('00'+convert(varchar(2),(datediff(dd,b.[ISO_WEEK_YEAR_START_DATE],a.[DATE])/7)+1),2) +
    		'-'+convert(varchar(1),(datediff(dd,@LOW_DATE,a.[DATE])%7)+1) ,
    --*/
    	[DATE_FORMAT_YYYY_MM_DD]		=
    		convert(char(10),a.[DATE],111) ,
    	[DATE_FORMAT_YYYY_M_D]		= 
    		convert(varchar(10),
    		convert(varchar(4),year(a.[DATE]))+'/'+
    		convert(varchar(2),day(a.[DATE]))+'/'+
    		convert(varchar(2),month(a.[DATE]))),
    	[DATE_FORMAT_MM_DD_YYYY]		= 
    		convert(char(10),a.[DATE],101) ,
    	[DATE_FORMAT_M_D_YYYY]		= 
    		convert(varchar(10),
    		convert(varchar(2),month(a.[DATE]))+'/'+
    		convert(varchar(2),day(a.[DATE]))+'/'+
    		convert(varchar(4),year(a.[DATE]))),
    	[DATE_FORMAT_MMM_D_YYYY]		= 
    		convert(varchar(12),
    		left(datename(month,a.[DATE]),3)+' '+
    		convert(varchar(2),day(a.[DATE]))+', '+
    		convert(varchar(4),year(a.[DATE]))),
    	[DATE_FORMAT_MMMMMMMMM_D_YYYY]	= 
    		convert(varchar(18),
    		datename(month,a.[DATE])+' '+
    		convert(varchar(2),day(a.[DATE]))+', '+
    		convert(varchar(4),year(a.[DATE]))),
    	[DATE_FORMAT_MM_DD_YY]		=
    		convert(char(8),a.[DATE],1) ,
    	[DATE_FORMAT_M_D_YY]		= 
    		convert(varchar(8),
    		convert(varchar(2),month(a.[DATE]))+'/'+
    		convert(varchar(2),day(a.[DATE]))+'/'+
    		right(convert(varchar(4),year(a.[DATE])),2))
    from
    	(
    	-- Derived table is all dates needed for date range
    	select	top 100 percent
    		[DATE_ID]	= aa.[NUMBER],
    		[DATE]		=
    			dateadd(dd,aa.[NUMBER],@LOW_DATE)
    	from
    		(
    		select
    			NUMBER = NUMBER+@start_no 
    		from
    			@num3
    		where
    			NUMBER+@start_no <= @end_no
    		) aa
    	order by
    		aa.[NUMBER]
    	) a
    	join
    	-- Match each date to the proper ISO week year
    	@ISO_WEEK b
    	on a.[DATE] between 
    		b.[ISO_WEEK_YEAR_START_DATE] and 
    		b.[ISO_WEEK_YEAR_END_DATE]
    order by
    	a.[DATE_ID]
     
    return
     
    Error_Exit:
     
    -- Return a pesudo error message by trying to
    -- convert an error message string to an int.
    -- This method is used because the error displays
    -- the string it was trying to convert, and so the
    -- calling application sees a formatted error message.
     
    declare @error int
     
    set @error = convert(int,@cr+@cr+
    '*******************************************************************'+@cr+
    '* Error in function F_TABLE_DATE:'+@cr+'* '+
    isnull(@ErrorMessage,'Unknown Error')+@cr+
    '*******************************************************************'+@cr+@cr)
     
    return
     
    end
    Elle s'utilise de cette maniere:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    select * from dbo.F_TABLE_DATE('2011-01-01','2012-01-01') -- genere les dates entre le premier janvier 2011 et premier janvier 2012
    et pour les charger directement dans une table:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    select * 
    into dim_date
    from dbo.F_TABLE_DATE('2011-01-01','2012-01-01')
    Personnellement j'avais fait une etape en plus car etant sur 2008R2, je trouvais dommage d'utiliser le type datetime pour des dates et j'ai donc fais le changement vers un type date.

    Bonne journee

  5. #5
    Membre habitué Avatar de scharly3
    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Novembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant en Business Intelligence

    Informations forums :
    Inscription : Novembre 2008
    Messages : 121
    Points : 144
    Points
    144
    Par défaut
    Ou encore avec une CTE Récursive:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    SET LANGUAGE 'FRENCH';
     
    WITH DateCTE
    AS (
        SELECT cast('20000101' AS DATETIME) Datevalue
     
        UNION ALL
     
        SELECT datevalue + 1
        FROM DateCTE
        WHERE datevalue + 1 < = '20151231'
        )
    SELECT cast(DATENAME(year, DateValue) AS INT) AS [Year]
        ,cast(DATENAME(year, DateValue) + REPLICATE('0', 2 - LEN(Month(DateValue))) + CAST(Month(DateValue) AS VARCHAR) AS INT) AS ID_Month
        ,cast(MONTH(DateValue) AS INT) AS [Month]
        ,cast(DATENAME(Month, DateValue) AS NVARCHAR(30)) AS [Lib_Month]
        ,cast(DATENAME(d, datevalue) AS INT) AS [Day]
        ,DATEPART(DW, datevalue) AS [Id_Lib_Day]
        ,cast(DATENAME(DW, Datevalue) AS NVARCHAR(10)) AS [Lib_Day]
        ,cast(DATENAME(WEEK, Datevalue) AS INT) AS [Week]
        ,CAST(Datevalue AS DATE) AS [Date]
        ,CAST(CONVERT(VARCHAR(8), Datevalue, 112) AS INT) AS idDate
        ,cast(DATENAME(dayofyear, Datevalue) AS INT) AS [DayOfYear]
    FROM DateCTE D
    ORDER BY Datevalue
    OPTION (MAXRECURSION 0)
    Source http://sauget-ch.fr/article-52-Gener...recursive.html

    Pas les solutions qui manquent
    Sauget Charles-Henri - MCITP Business Intelligence Developer 2008 - http://www.sauget-ch.fr

  6. #6
    Invité
    Invité(e)
    Par défaut
    Merci à tous pour vos réponses ! Comme je m'y attendais, c'est une problématique récurrente et je vois que je ne suis pas le seul à y être confronté.

    Merci à Nished pour cet article (que j'ai commenté) qui m'a permis d'avoir une vue d'ensemble des solutions utilisables - peut-être non exhaustive, je n'ai pas le recul et l'expérience nécessaires sur ces sujets pour en juger - . J'ai finalement opté pour la création d'une table "Temps" dans mon entrepôt de données, au moyen d'un script sql basé sur le script fourni dans l'article de Nished :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    -- Création d'une table de dimension temps pour Analysis Services
    -- Chaque enregistrement correspond à une date
    -- Paramètres : @startdate et @enddate
     
    DROP TABLE TimeDimension
    GO
    CREATE TABLE TimeDimension
    (
    	DateID			DATE		NOT NULL PRIMARY KEY,
       	MonthName		VARCHAR(9) 	NOT NULL,
       	MonthName_FR	VARCHAR(9),
       	MonthNumber		INT        	NOT NULL,
       	DayNumber		INT        	NOT NULL,
       	DayName			VARCHAR(9) 	NOT NULL,
       	DayName_FR		VARCHAR(8),
       	Quarter			INT        	NOT NULL,
       	QuarterName		CHAR(7)		NOT NULL,
       	Year			INT        	NOT NULL
    )
    GO
    BEGIN
    	SET DATEFIRST 1
    	DECLARE @startdate  DATETIME
    	DECLARE @enddate    DATETIME
    	DECLARE @date       DATETIME
    	DECLARE @offset     INT
    	DECLARE @dateId		DATE
    	SET     @startdate  = '2010-01-01'
    	SET     @enddate    = '2012-12-31'
    	SET     @offset     = 0
    	SET     @date       = DATEADD(dd, @offset, @startdate)
    	WHILE @date <= @enddate
    	BEGIN
    		SET @dateId = @date
     
    		INSERT INTO TimeDimension(DateID,MonthName,MonthNumber,DayNumber,DayName,Quarter,QuarterName,Year)
    		VALUES (@dateId,				--DateID
    			DATENAME(mm, @date),		--MonthName
    			DATEPART(mm, @date),		--MonthNumber
    			DATEPART(dd, @date),		--DayOfMonth
    			DATENAME(DW, @date),		--DayNAme
    			DATEPART(qq, @date),		--Quarter
    			'Q' + DATENAME(qq, @date),	--QuarterName
    			DATEPART(yy, @date)		--Year
    		)
    		SET  @offset	= @offset + 1
    		SET  @date  	= DATEADD(dd, @offset, @startdate)
    	END
    END
    GO
     
    -- Conversions des noms de jours et de mois en Français
    SET LANGUAGE French
    UPDATE TimeDimension SET DayName_FR = DATENAME(DW, DateId), MonthName_FR = DATENAME(mm, DateId)
    SET LANGUAGE US_English
    Merci à tous pour vos réponses qui m'ont permis d'y voir plus clair
    Je marque ce sujet comme résolu.

  7. #7
    Membre émérite Avatar de FrancoisJehl
    Homme Profil pro
    BI Engineer
    Inscrit en
    Juillet 2009
    Messages
    1 485
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : BI Engineer
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juillet 2009
    Messages : 1 485
    Points : 2 883
    Points
    2 883
    Par défaut
    Par contre en termes de perfs l'utilisation d'une CTE pour la génération d'une table séquentielle aura de meilleures perfs que le While, c'est un truc bien connu depuis ce post de Jamie Thomson (http://consultingblogs.emc.com/jamie...-of-dates.aspx), que Charles-Henri (scharly3) reprend et détaille très bien dans son blog (l'URL qu'il t'a donné) et dans ce post.
    Aaron Bertrand sur un sujet transverse explique bien que les WHILE c'est pas gégé pour générer des séquences de nombres:
    http://sqlblog.com/blogs/aaron_bertr...e-a-table.aspx
    François JEHL
    BI Engineer | MVP SQL Server
    http://fjehl.wordpress.com
    Pour me contacter, par MP ou ici, mais pas pour des questions techniques.

    /*
    Avant de poster cherchez dans la FAQ et utilisez la fonction "Rechercher" du forum.
    Au moment de poster, posez votre question dans le bon sous-forum (Débuter, SSAS, SSRS, SSIS), en utilisant les TAGs prédéfinis ([2K], [2K5], [2K8], [2K8R2]).
    */

  8. #8
    Invité
    Invité(e)
    Par défaut
    En effet, cependant c'est surtout un réel souci dans le cas où ce recours à la boucle while est récurrent et fréquent, d'après ce que j'en ai compris ? Dans le cas présent, il s'agit de générer une fois pour toutes la dimension temps, avec l'ensemble des dates entre deux bornes, et de ne plus la modifier.

    Je me pencherai néanmoins sur l'utilisation d'une CTE comme vous me le conseillez, pour ma culture personnelle principalement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Gestion de la dimension temps dans un entrepôt de Données
    Par jojodebabi dans le forum Approche théorique du décisionnel
    Réponses: 3
    Dernier message: 27/04/2015, 10h37
  2. [SSAS] [2K5] Gestion de deux dates + Dimension Temps.
    Par BoromSikim dans le forum SSAS
    Réponses: 4
    Dernier message: 13/01/2010, 11h15
  3. [Data WareHouse] Alimenter dimension temps
    Par gg9595 dans le forum Alimentation
    Réponses: 9
    Dernier message: 30/08/2007, 19h31
  4. gestion d'emploi de temps du professeur
    Par fadwa01 dans le forum Langage
    Réponses: 2
    Dernier message: 23/03/2007, 14h42
  5. [9.2i] Créer une dimension temps pour un DWH
    Par alpachico dans le forum Oracle
    Réponses: 5
    Dernier message: 28/10/2005, 15h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo