Solutions to SQL Server database Problems

Source: Internet
Author: User
Tags mssql server

Symptom: the database log is too large, so the shrink cannot be dropped. So I want to unload the database file, delete the log, and attach it. Attaching failed.
Error message:
Server: Message 1813, level 16, status 2, Row 1
The new database 'metadb' cannot be opened '. Create database will be terminated.
Device activation error. The physical file name 'd: \ metadb. ldf' may be incorrect.
Environment: MSSQL Server 2000 Enterprise Edition

Solution Process:
1. Create a new database newdb
2. Stop the database. Delete the log file of the new database. metadb. MDF overwrites newdb. MDF.
3. Start the database server. The status of the database newdb is "questionable ".
4. allow direct modification to the system directory
Use master
Go
Sp_configure 'Allow updates', 1
Go
Reconfigure with override
Go
Update sysdatabases set status =-32768 where dbid = db_id ('newdb ')
5. Rebuild log
DBCC rebuild_log ('newdb', 'c: \ Program Files \ Microsoft SQL Server \ MSSQL \ data \ newdb_log.ldf ')
6. DBCC check
DBCC checkdb ('newdb ')
7. Set the database to normal
Sp_dboption 'newdb', 'dbo use only', 'false'
8 direct modification to the system directory is not allowed
Sp_configure 'Allow updates', 0
Go
Reconfigure with override
Go

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.