(If you want to reprint, please specify the source!), if you have any questions, please send mail to me:-)
***********************************************************
In the case of MS SQL Server, where the state of SQL Server is "questionable", let us first analyze the reason for the SQL Server database "suspect":
1. Incorrect deletion of log;
2. Hardware (HD) damage, resulting in log and data file write errors;
3. Hard disk space is not enough, such as log file is too large;
Solution:
The easiest way to do this is to have a full backup of the database and then restore it.
Steps:
1. Delete the original database:
Use MASTER
Go
DROP DATABASE Db_suepect
2. Establishment of a database with the same name:
Use master
Go
CREATE DATABASE Db_suspect
On
(NAME = Dbname_dat,
FILENAME = ' C: ',
SIZE = 10,
FILEGROWTH = 5)
LOG on
(NAME = ' Dbname_log ',
FILENAME = ' g: ',
SIZE = 5MB,
FileGrowth = 5MB)
Go
3. Restore the database:
RESTORE DATABASE Db_suspect
From Dbname_backup. Dat
If you don't have full backups, you'll need to use some special methods:
1. Set Database as emergency mode
Use Master
Go
sp_configure ' allow updates ', 1
Reconfigure with override
Go
UPDATE sysdatabases SET status = 32768 where name = ' Db_suspect '
Go
2. Deactivate SQL Server service:
NET STOP MSSQLServer
3. Dbname_dat the data file of the original database. Mdf,dbname_log. LDF removal:
4. Start SQL Server service:
NET START MSSQLServer
5. Re-establishing a database db_suspect with the same name;
Use master
Go
CREATE DATABASE Db_suspect
On
(NAME = Dbname_dat,
FILENAME = ' C: ',
SIZE = 10,
FILEGROWTH = 5)
LOG on
(NAME = ' Dbname_log ',
FILENAME = ' g: ',
SIZE = 5MB,
FileGrowth = 5MB)
Go
6. Set the database to run in Single-user mode:
Use MASTER
Go
ALTER DATABASE db_suspect SET single_user
Go
7. Stop SQL Service:
NET STOP MSSQLServer
8. Overwrite the original data file back:
9. Start SQL Server service:
NET START MSSQLServer
10. Reset the state of SQL Server:
Use MASTER
Go
EXEC sp_resetstatus "Db_suspect"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.