Erstellen Sie eine Partition-Funktion in SQL

Habe ich eine partition Funktion, aber ich bin nicht in der Lage, wenden Sie es auf einen Tisch. Ich bin mir nicht sicher, wohin ich gehe falsch.

Hier ist meine partition-Funktion:

     CREATE PARTITION FUNCTION StaticDateMonthPartition (int)
     AS RANGE left
     FOR VALUES     (   
                    20120301,
                    20120401,
                    20120501,
                    20120601,
                    20120701,
                    20120801,
                    20120901,
                    20121001,
                    20121101,
                    20121201,
                    20130101,
                    20130201
                    )

versuchen, beziehen sich auf diese Tabelle:

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[partition_OLAP_Fact_vvv]') AND type in (N'U'))
    DROP TABLE [dbo].[partition_OLAP_Fact_vvv]
    GO

    CREATE TABLE [dbo].[partition_OLAP_Fact_vvv]
    (
        FFFFactvvvId            bigint,
        CORStaticDateId         int,
        CORVersionvvvId         bigint,
        vvvCount                tinyint,
        UPB                     decimal(18, 2)
    ) ON  CORStaticDateMonthPartition ([CORStaticDateId])

Aber wenn ich versuche, führen Sie die Tabelle Skript bekomme ich diesen Fehler:

    Invalid partition scheme 'CORStaticDateMonthPartition' specified

Bitte Helfen.


Umbuchung meinen code, mit den Schritten

Pinal ist tutoral ist toll! Hier ist eine kurze Zusammenfassung

  1. Datei hinzufügen von Gruppen für alle Ihre Partitionen

    Alter Database [database]   Add FileGroup partition_201207
  2. Create Partition Function

    CREATE PARTITION FUNCTION Partition_Range_CORStaticMonth(int)
    AS RANGE left
    FOR VALUES (20120301)
  3. Create Partition Scheme

    CREATE PARTITION SCHEME Partition_Scheme_CORStaticMonth
    AS PARTITION Partition_Range_CORStaticMonth
    TO (FFF_Fact_vvv_201203)
  4. Hinzufügen von Dateien zu Datei-Gruppen

    ALTER DATABASE [database] 
    ADD FILE( 
            NAME = N'FFF_Fact_vvv_201203', 
            FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\FFF_Fact_vvv_201203.ndf' , 
            SIZE = 2048KB , 
            FILEGROWTH = 1024KB 
            ) 
    TO FILEGROUP [FFF_Fact_vvv_201203]
  5. Tabelle erstellen mit Partition-Schema angewendet

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[partition_Table]') AND type in (N'U'))
    DROP TABLE [dbo].[partition_Table]
    GO
    
    CREATE TABLE [dbo].[partition_Table]
    (
        CORStaticDateId         int
    ) ON  Partition_Scheme_CORStaticMonth ([CORStaticDateId])
Warum sind Sie die Speicherung von Daten, die als ints eher als, hmm, sagen dates?
es ist eine Tatsache, die Tabelle, die feeds in unser SSAS-cube. Das wahre Datum existiert in der date-dimension
perfekte Ansatz zum speichern von Daten wie ganze zahlen auf ein DW
Ich hatte das Glück zu Erben,

InformationsquelleAutor king conch | 2012-05-15

Schreibe einen Kommentar