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

SQL switch recovery model (BULK-LOGGED to SIMPLE e viceversa)

Multidatabase : Switch da MODEL BULK-LOGGED a SIMPLE e viceversa

--SET BULK-LOGGED MODE

USE master
GO


-- Declare a variable to store the value [database name] returned by FETCH.
DECLARE @dbname sysname, @cmd varchar(1000)

-- Declare a cursor to iterate through the list of databases
DECLARE db_recovery_cursor CURSOR FOR
SELECT name from sysdatabases
-- Open the cursor
OPEN db_recovery_cursor

-- Perform the first fetch and store the value in a variable.
FETCH NEXT FROM db_recovery_cursor INTO @dbname

-- loop through cursor until no more records fetched
WHILE @@FETCH_STATUS = 0
BEGIN
-- create the alter database command for each database
SET @cmd = 'ALTER DATABASE "' + @dbname + '" SET RECOVERY BULK-LOGGED '
-- alter each database setting the recovery model to FULL
EXEC(@cmd)
PRINT @dbname
-- fetch the next database name
FETCH NEXT FROM db_recovery_cursor INTO @dbname
END
-- close the cursor and deallocate memory used by cursor
CLOSE db_recovery_cursor
DEALLOCATE db_recovery_cursor

 

Shrinking
Example:

backup log db_name with TRUNCATE_ONLY

SHRINKFILE
DBCC SHRINKFILE(db_name_dat,1)
DBCC SHRINKFILE(db_name_log,1)

Categoria: Sql Server ALL
mercoledì, 03 feb 2010 Ore. 14.03

Messaggi collegati


Statistiche
  • Views Home Page: 471.750
  • Views Posts: 889.030
  • 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