Partition Function

  •  

    CREATE PARTITION FUNCTION [HourRangePF1](datetime) AS RANGE RIGHT FOR VALUES (N'1900-01-01 01:00:00', N'1900-01-01 02:00:00', N'1900-01-01 03:00:00', N'1900-01-01 04:00:00', N'1900-01-01 05:00:00', N'1900-01-01 06:00:00', N'1900-01-01 07:00:00', N'1900-01-01 08:00:00', N'1900-01-01 09:00:00', N'1900-01-01 10:00:00', N'1900-01-01 11:00:00', N'1900-01-01 12:00:00', N'1900-01-01 13:00:00', N'1900-01-01 14:00:00', N'1900-01-01 15:00:00', N'1900-01-01 16:00:00', N'1900-01-01 17:00:00', N'1900-01-01 18:00:00', N'1900-01-01 19:00:00', N'1900-01-01 20:00:00', N'1900-01-01 21:00:00', N'1900-01-01 22:00:00', N'1900-01-01 23:00:00')

    I have created a partition function. It is like there are 24 partitions and for each hour of a day one partition. for example if I insert data at 1 am(the table has a timestamp column based upon that the function works) the data should go to the partition one. Will the above code acheive the functionality. Is there any way in which I can select the data in a particular partition?

    Thanks in advance

     

    with smiles

    santhosh

    CREATE PARTITION FUNCTION [HourRangePF1](datetime) AS RANGE RIGHT FOR VALUES (N'1900-01-01 01:00:00', N'1900-01-01 02:00:00', N'1900-01-01 03:00:00', N'1900-01-01 04:00:00', N'1900-01-01 05:00:00', N'1900-01-01 06:00:00', N'1900-01-01 07:00:00', N'1900-01-01 08:00:00', N'1900-01-01 09:00:00', N'1900-01-01 10:00:00', N'1900-01-01 11:00:00', N'1900-01-01 12:00:00', N'1900-01-01 13:00:00', N'1900-01-01 14:00:00', N'1900-01-01 15:00:00', N'1900-01-01 16:00:00', N'1900-01-01 17:00:00', N'1900-01-01 18:00:00', N'1900-01-01 19:00:00', N'1900-01-01 20:00:00', N'1900-01-01 21:00:00', N'1900-01-01 22:00:00', N'1900-01-01 23:00:00')

    I have created a partition function. It is like there are 24 partitions and for each hour of a day one partition. for example if I insert data at 1 am(the table has a timestamp column based upon that the function works) the data should go to the partition one. Will the above code acheive the functionality. Is there any way in which I can select the data in a particular partition?

    Thanks in advance

     

    with smiles

    santhosh

  • This was removed by the editor as SPAM

  • The partitions you created are (t<1900-01-01 1:00:00), (1900-01-01 1:00:00=<t<1900-01-01 2:00:00), ...

    So in fact if you insert data at 1:00am, the data will go to the 2nd partition.

    To retrieve all data from a certain partition (@PartitionNumber):

    SELECT * FROM schema.tableName WHERE $PARTITION.HourRangePF1(TimeColumnInTable)=@PartitionNumber

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply