Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/10/2015, 01:31
encarna1986
 
Fecha de Ingreso: octubre-2015
Mensajes: 4
Antigüedad: 8 años, 7 meses
Puntos: 0
Respuesta: Borrar file y file group tabla particionada - Transact-SQL

Lo primero muchas gracias por responder y leerte mi post.

Te comento, la primera partición no la elimino ya que supuestamente es la que se reserva el sistema, entonces, los datos que muevo son los de la "segunda" partición por así decir, no obstante cuando hago el split para moverlos, si que indico que es la primera, ya que es la que me aparece con datos...creo que algo no lo estoy haciendo bien y se me escapa

Lo cierto es que una vez que he movido los datos de la partición que tengo que eliminar y están vacíos los file y file group no puedo eliminarlos con lo que se queda el espacio asignado. He probado lo siguiente y tampoco me funciona

-->amplio espacio al file:

GO
ALTER DATABASE pruebas_particion
MODIFY FILE
(NAME = file_prueba_particion_20120928,
SIZE = 50000MB);
GO

--> Intento vacíarlo y me devuelve error:

DBCC SHRINKFILE (file_prueba_particion_20120928, EMPTYFILE)


SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files where name ='file_prueba_particion_20120928';

file_prueba_particion_20120928 499.875000

DBCC SQLPERF(LOGSPACE);
GO

DBCC SHRINKFILE (file_prueba_particion_20120928, EMPTYFILE)
--DEVUELVE ERROR

--revisamos los datos que hay en el filegroup

SELECT OBJECT_NAME(object_id), *
FROM sys.data_spaces ds INNER JOIN sys.allocation_units au
ON ds.data_space_id = au.data_space_id
INNER JOIN sys.partitions p
ON au.container_id = CASE WHEN au.type = 2 THEN p.partition_id ELSE p.hobt_id END
WHERE ds.name = 'fg_prueba_particion_20120928'

--Existe el filegroup prueba_particion fg_prueba_particion_20120928

GO
ALTER DATABASE pruebas_particion SET SINGLE_USER WITH NO_WAIT
GO
DBCC CHECKDB (pruebas_particion,REPAIR_REBUILD)
GO
ALTER DATABASE pruebas_particion SET MULTI_USER WITH NO_WAIT

DBCC SHRINKFILE ('file_prueba_particion_20120928', EMPTYFILE)
--DEVUELVE ERROR


Alter Database pruebas_particion remove file file_prueba_particion_20120928

Alter Database pruebas_particion remove filegroup fg_prueba_particion_20120928

Msg 5042, Level 16, State 1, Line 1
The file 'file_prueba_particion_20120928' cannot be removed because it is not empty.

¿Sabes que le puede suceder?

Mil millones de gracias