RS First Dynamics NAV Blog


...from NAV 3.60 to NAV 2013
Archivio Posts
Anno 2015

Anno 2014

Anno 2013

Anno 2012

Anno 2011

Anno 2010

Anno 2009

Anno 2008

Anno 2007

Shrink datafiles with Sql Script

Uno script per compattare tutti i datafiles rilasciando spazio

a scritp to compact alla datfiles with space relesing at the end

USE Database

GO
DECLARE @fileid as int
DECLARE @name as varchar(50)
DECLARE contact_cursor CURSOR FOR
SELECT file_id, name
FROM sys.database_files;

OPEN contact_cursor;
FETCH NEXT FROM contact_cursor
INTO @fileid, @name;

WHILE @@FETCH_STATUS = 0
BEGIN
    --Shrink datafile. Rilascia tutto lo spazio disponibile alla fine del file sistema operativo.
   DBCC SHRINKFILE (@fileid, TRUNCATEONLY);
   FETCH NEXT FROM contact_cursor
   INTO @fileid, @name;
END
CLOSE contact_cursor;
DEALLOCATE contact_cursor;

Categoria: Sql Server ALL
giovedì, 02 set 2010 Ore. 09.42

Messaggi collegati


Statistiche
  • Views Home Page: 452.110
  • Views Posts: 864.744
  • Views Gallerie: 0
  • n° Posts: 343
  • n° Commenti: 0
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003