In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what to do about the Sql Server query database. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
1. First make sure that the .MDF and .ldf files have been backed up.
two。 Create a new database with the same name in SQL Server, and then stop the SQL Server service.
3. Overwrite the .MDF and .ldf files corresponding to the new database with the original .MDF and .ldf files.
4. Restart the SQL Server service, which should see that the database is in a Suspect state.
5. Execute the following command in the SQL query Analyzer to allow system tables to be updated:
Use master
Go
Sp_configure 'allow updates',1
Reconfigure with override
Go
6. Put this database in emergency mode:
Update sysdatabases set status = 32768 where name = 'db_name'
Go
7. Use the DBCC CHECKDB command to check the database for errors:
DBCC CHECKDB ('db_name')
GO
8. If the DBCC CHECKDB command fails, go to step 10, otherwise put the database into single-user mode and then try to fix it:
Sp_dboption 'db_name','single user','true'
DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS)
GO
If the DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS) command prompts that the database is not in single-user mode, restart the SQL Server service and continue to try.
9. If the DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS) command fails, go to step 10, otherwise if you successfully fix the error in the database:
Re-execute the DBCC CHECKDB ('db_name') command to verify that there are no errors in the database.
Clear the suspect status of the database: sp_resetstatus' db_name'
Clear the single-user mode state of the database: sp_dboption 'db_name','single user','false'
Restart the SQL Server service, and if everything is all right, the database has been successfully restored.
10. If none of the above steps solve the problem, refer to the documentation in the attachment and try to restore the data in the database by rebuilding the transaction log.
If you only have the MDF file, the problem is more complicated, and we need to rebuild the transaction log directly:
1. Create a new database with the same name in SQL Server, and then stop the SQL Server service.
two。 Overwrite the .MDF file corresponding to the new database with the original ldf file and delete its log file (.ldf).
3. Start the SQL Server service and put the database in emergency mode (ibid.: steps 5 and 6).
4. Stop and restart the SQL Server service.
5. Execute the following command to rebuild the database log file: (here is an example where you want to use your actual database name)
DBCC REBUILD_LOG ('cas_db',' D:\ cas_db\ cas_db_Log.LDF')
6. Reset the database to single-user mode.
7. Try again to check and fix errors in the database using the DBCC CHECKTABLE or DBCC CHECKDB command.
This is the end of the article on "what to do with the Sql Server query database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.