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

DB Sql Server "Change Db Status"

Change the database context to Master and allow updates to system tables:
   Use Master
   Go
   sp_configure 'allow updates', 1
   reconfigure with override
   Go


Set the database in Emergency (bypass recovery) mode:
   select * from sysdatabases where name = '<db_name>'
   -- note the value of the status column for later use in # 6
   begin tran
   update sysdatabases set status = 32768 where name = '<db_name>'
   -- Verify one row is updated before committing
   commit tran


Stop and restart SQL server.

Call DBCC REBUILD_LOG command to rebuild a "blank" log file based on the
suspected db.
      The syntax for DBCC REBUILD_LOG is as follows:
   DBCC rebuild_log('<db_name>','<log_filename>')

   where <db_name> is the name of the database and <log_filename> is
   the physical path to the new log file, not a logical file name. If you
do not
   specify the full path, the new log is created in the Windows NT system
root
   directory (by default, this is the Winnt\System32 directory).


Set the database in single-user mode and run DBCC CHECKDB to validate
   physical consistency:
   sp_dboption '<db_name>', 'single user', 'true'
   DBCC checkdb('<db_name>')
   Go
   begin tran
   update sysdatabases set status = <prior value> where name = '<db_name>'
   -- verify one row is updated before committing
   commit tran
   Go

Turn off the updates to system tables by using:
   sp_configure 'allow updates', 0
   reconfigure with override
   Go

Categoria: Sql Server ALL
lunedì, 22 feb 2010 Ore. 17.44

Messaggi collegati


Statistiche
  • Views Home Page: 471.751
  • Views Posts: 889.048
  • 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