Tuesday, 19 February 2008

Suspect Database

sp_configure 'allow updates', 1 Reconfigure with override
sp_resetstatus 'crm'
sp_configure 'allow updates', 0 Reconfigure with override

restart sql service

If the databse is still suspect put it into emergency mode and extract the data

sp_configure 'allow updates', 1 Reconfigure with override
UPDATE master..sysdatabases SET status = 32768 WHERE name = 'DatabaseName'
restart sql service

Should now be able to use DTS or BCP to get the data out

No LDF and sp_detachdb not Run

1. Copy good mdf to new location
2. Create new database with same dbname, file names and locations.
3. Stop services
4. Copy good mdf and replace new empty mdf
5. Restart services - database will be suspect
6. Setup server to updates to sysdatabases:

Use Master
Go
sp_configure 'allow updates', 1
reconfigure with override
Go

7. Put database in emergency mode:

update sysdatabases set status = 32768 where name = ''

8. Stop and start services again - database should be marked in emergency mode
9. Rebuild the log file:

DBCC TRACEON (3604)
DBCC REBUILD_LOG('','')
Go

10. DBCC CHECKDB(,REPAIR_REBUILD)