Ver Mensaje Individual
  #11 (permalink)  
Antiguo 03/12/2012, 07:54
roskiya
 
Fecha de Ingreso: febrero-2009
Mensajes: 8
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Particionar Tabla cuando haya un mes nuevo

así cree las particiones para cada mes.

Cita:
--Create date partition function with increment by month.

DECLARE @DatePartitionFunction nvarchar(max) = 'CREATE PARTITION FUNCTION FuncionParticion (date) AS RANGE LEFT FOR VALUES (';
DECLARE @i date = '2013-01-31';
DECLARE @o int = 0
WHILE @o <= 11
BEGIN

SET @DatePartitionFunction += 'N''' + CAST(DATEADD(month, @o, @i) as nvarchar(10)) + ''',';
SET @o = (@o+1);

END
SET @DatePartitionFunction += 'N''' + CAST(DATEADD(month, @o, @i) as nvarchar(10))+ ''')';

EXEC sp_executesql @DatePartitionFunction;
GO

CREATE PARTITION SCHEME EsquemaParticion AS PARTITION FuncionParticion ALL TO ( GrupoArchivos );
con una tabla con 5 millones de datos tiene una eficiencia del 10% aprox.

PD: El esquema de particion estan todas las particiones en el mismo grupo de archivos ( pueden cambiarse a otros discos duros para mejorar mas aun el rendimiento).

¿¿Alguna duda??