SQL Server 返回了错误 21(设备未就绪。) 解决方法
错误 描述: /Web应用程序中的服务器 错误 。 在文件 'G:\LedDB\LedDB.mdf' 中、偏移量为 0x00000001a9a000 的位置执行 读取 期间,操作系统已经向 SQL Server 返回 了 错误 21( 设备 未 就绪 。 ) 。 SQL Server 错误 日志和系统事件日志中的其他消息可能提
错误描述:
“/Web”应用程序中的服务器错误。
在文件'G:\LedDB\LedDB.mdf' 中、偏移量为0x00000001a9a000 的位置执行 读取 期间,操作系统已经向SQL Server 返回了错误21(设备未就绪。)。SQL Server 错误日志和系统事件日志中的其他消息可能提供了更详细信息。这是一个威胁数据库完整性的严重系统级错误条件,必须立即纠正。请执行完整的数据库一致性检查(DBCC CHECKDB)。此错误可以由许多因素导致;有关详细信息,请参阅SQL Server 联机丛书。
说明: 执行当前Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 在文件'G:\LedDB\LedDB.mdf' 中、偏移量为0x00000001a9a000 的位置执行 读取 期间,操作系统已经向SQL Server 返回了错误21(设备未就绪。)。SQL Server 错误日志和系统事件日志中的其他消息可能提供了更详细信息。这是一个威胁数据库完整性的严重系统级错误条件,必须立即纠正。请执行完整的数据库一致性检查(DBCC CHECKDB)。此错误可以由许多因素导致;有关详细信息,请参阅SQL Server 联机丛书。
解决方法
重启SqlServer服务,确保没有其他链接连接到当前错误数据库
执行
usemaster
declare@databasename varchar(255)
set@databasename='leddb'
execsp_dboption @databasename, N'single', N'true'--将目标数据库置为单用户状态
dbcccheckdb(@databasename,REPAIR_ALLOW_DATA_LOSS)
dbcccheckdb(@databasename,REPAIR_REBUILD)
execsp_dboption @databasename, N'single', N'false'--将目标数据库置为多用户状态
即可
相关资料:
MS Sql Server 提供了很多数据库修复的命令,当数据库质疑或是有的无法完成读取时可以尝试这些修复命令。
1. DBCC CHECKDB
重启服务器后,在没有进行任何操作的情况下,在SQL查询分析器中执行以下SQL进行数据库的修复,修复数据库存在的一致性错误与分配错误。
use master
declare @databasename varchar(255)
set @databasename='需要修复的数据库实体的名称'
exec sp_dboption @databasename, N'single', N'true' --将目标数据库置为单用户状态
dbcc checkdb(@databasename,REPAIR_ALLOW_DATA_LOSS)
dbcc checkdb(@databasename,REPAIR_REBUILD)
exec sp_dboption @databasename, N'single', N'false'--将目标数据库置为多用户状态
然后执行 DBCC CHECKDB('需要修复的数据库实体的名称') 检查数据库是否仍旧存在错误。注意:修复后可能会造成部分数据的丢失。
2. DBCC CHECKTABLE
如果DBCC CHECKDB 检查仍旧存在错误,可以使用DBCC CHECKTABLE来修复。
use 需要修复的数据库实体的名称
declare @dbname varchar(255)
set @dbname='需要修复的数据库实体的名称'
exec sp_dboption @dbname,'single user','true'
dbcc checktable('需要修复的数据表的名称',REPAIR_ALLOW_DATA_LOSS)
dbcc checktable('需要修复的数据表的名称',REPAIR_REBUILD)
------把’ 需要修复的数据表的名称’更改为执行DBCC CHECKDB时报错的数据表的名称
exec sp_dboption @dbname,'single user','false'
3. 其他的一些常用的修复命令
DBCC DBREINDEX 重建指定数据库中表的一个或多个索引
用法:DBCC DBREINDEX (表名,’’) 修复此表所有的索引。
===================================
SQL SERVER数据库的检测及修复方法
随着K/3产品的推广,要求客户服务人员对SQL SERVER数据库的了解也进一步提高。在K/3的使用过程中,数据库文件被频繁地使用,由于某些原因,数据库有可能被损坏,本文将针对这种情况的数据库检测及修复方法做一简单讲解。希望各位在实际工作过程中有新的发现时,及时给我们提供信息,以便做进一步的更新。
1.1 SQL SERVER数据库的检测
SQL SERVER提供了数据库检测的命令,可用DBCC CHECKDB对数据库中各个对象的分配及结构的正确性进行检测,并可通过一参数控制,将所有的错误信息显示出来。其语法如下:
DBCC CHECKDB
('database_name' [,NOINDEX | { REPAIR_ALLOW_DATA_LOSS
| REPAIR_FAST
| REPAIR_REBUILD
}]
) [WITH {ALL_ERRORMSGS | NO_INFOMSGS}]
参数说明:
'database_name'代表被检测的数据库实体名;
NOINDEX指非系统表的非聚族索引不检测;
REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST| REPAIR_REBUILD 指直接修复发现的错误,其中REPAIR_ALLOW_DATA_LOSS代表,若此错误不能修复时,系统将直接删除相关数据。带此三个参数的任一个时,数据库必须处于单用户模式,可在Enterprise Manager中的数据库属性中设置;
ALL_ERRORMSGS代表将检测到的错误信息全部显示出来,否则,对于每张表最多只显示200条错误信息;
NO_INFOMSGS代表隐藏所有的信息及占用空间的报告。
经过检测,对于错误的对象,将以OBJECT ID的形式报告具体出错的信息,可根据OBJECT ID到系统表sysobjects中查找到相关的表,即NAME。
1.2 SQL SERVER问题数据库的修复
经过数据库检测后,可针对出现的问题采取相应的措施进行处理。如通过检测后,发现对象的物理存放存在问题,可用DBCC CHECKALLOC来进行修复:
DBCC CHECKALLOC ('database_name' | REPAIR_REBUILD }] ) [WITH {ALL_ERRORMSGS | NO_INFOMSGS}]
若是非系统对象的索引出错,则可用DBCC DBREINDEX进行修复:
DBCC DBREINDEX ( [ 'database.owner.table_name' [, index_name [, fillfactor ] ] ] ) [WITH NO_INFOMSGS]
以上两种情况,也可直接使用DBCC CHECKDB(‘db_name’,repair_rebuild)来修复。
另外一种情况是在进行检测时,提示无法建立数据连接,此时表明,数据库已损坏。对于这种情况,我们可采取如下措施来尝试修复。
首先,在SQL Enterprise中新建一数据库(如数据库名为test),建好数据库后,停止SQL Server Service Manager,并将客户数据库的MDF文件更名为test _data.mdf(即新建数据库的主文件名),然后用更名后的文件覆盖新建数据库同名文件,接着,启动SQL Server Service Manager。对Master数据库将系统表设置为可更改状态
Use Master
Go
sp_configure 'allow updates', 1
reconfigure with override
Go
将数据库设为紧急状态:
update sysdatabases set status = 32768 where database '
停止并重新启动SQL Server Service Manager,并重建Log文件:
DBCC TRACEON (3604)
DBCC REBUILD_LOG(' test ','test _log_ldf')
将数据库设置为单用户模式,然后进行检测:
sp_dboption ' test ', 'single user', 'true'
DBCC CHECKDB(' test ')
Go
此数据库执行CHECKDB的过程中发现一些表的索引被破坏,于是针对具体的表进行重建索引的操作:
DBCC DBREINDEX(表名)
如执行以上操作仍然不能解决,若索引破坏的表是临时表或不是关键表,则可从新建账套中引入,若是主表,则可能通过近期的备份来(部份)恢复。若没有一个备份,则无法修复。
1.3 SQL Server数据库为什么易损坏呢?
以下是微软提供的一些可能引起数据库损坏的原因及一些预防措施:
操作问题,包括冷起动机器、热拔硬盘、删除一些数据库文件;
硬件问题,包括磁盘控制器的问题;
操作系统问题,包括与系统相关的一些致命错误。
1.4 预防措施:
1、定期/不定期执行CHKDSK(不带参数),以检测硬盘物理结构并修复一些CHKDSK报告的问题;
2、常备份数据。
1.5 应用数据库修复举例
declare @databasename varchar(255)
set @databasename='AIS20021224170730'------一定要手工输入
---------执行一般性修复还存在问题时,进行允许数据丢失的修复
---------许数据丢失的修复要求在单用户下进行,此时请退出中间层,客户端,sql的其他模块
---所有功能退出,在查询分析器master里设置数据库为单用户
exec sp_dboption @databasename, N'single', N'true'
-----在查询分析器master里,进行修复数据库
dbcc checkdb(@databasename,REPAIR_ALLOW_DATA_LOSS)
dbcc checkdb(@databasename,REPAIR_REBUILD)
------还原数据库状态
exec sp_dboption @databasename, N'single', N'false'
第2章数据库日志损坏的修复
请遵照如下步骤来试图重建数据库事务日志.
注意: 由于事务日志丢失, 数据库可能有没有提交的数据.
注:都要替换成真实的数据库名字
2.1 步骤1:
创建一个新的数据库,命名为原来数据库的名字.
2.2步骤2:
停止SQL Server
2.3步骤3:
把老数据库的MDF文件替换新数据库的相应的MDF文件, 并把LDF文件删除
2.4步骤4:
重新启动SQL Server 服务,然后运行如下命令:
Use Master
Go
sp_configure 'allow updates', 1
reconfigure with override
Go
begin tran
update sysdatabases set status = 32768 where db_name'
-- Verify one row is updated before committing
commit tran
2.5步骤5:
停止SQL然后重新启动SQL Server 服务,然后运行如下命令:
DBCC TRACEON (3604)
DBCC REBUILD_LOG('db_name','c:\mssql7\data\dbxxx_3.LDF')
Go
2.6步骤6:
停止SQL然后重新启动SQL Server 服务,然后运行:
use master
update sysdatabases set status = 8 where
Go
sp_configure 'allow updates', 0
reconfigure with override
Go
2.7步骤7:
运行dbcc checkdb(db_name)检查数据库的完整性.
第3章 数据库质疑的一般处理
1、执行如下SQL(打开修改系统表的开关):
EXEC sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE
2、修改数据库Master中的表:sysdatabases
将 status字段数值更改为4
3、再执行如下SQL:
EXEC sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Table of Contents Solution 1 Solution 21. Delete the temporary files of Windows update 2. Repair damaged system files 3. View and modify registry entries 4. Turn off the network card IPv6 5. Run the WindowsUpdateTroubleshooter tool to repair 6. Turn off the firewall and other related anti-virus software. 7. Close the WidowsUpdate service. Solution 3 Solution 4 "0x8024401c" error occurs during Windows update on Huawei computers Symptom Problem Cause Solution Still not solved? Recently, the web server needs to be updated due to system vulnerabilities. After logging in to the server, the update prompts error code 0x8024401c. Solution 1

Unfortunately, people often delete certain contacts accidentally for some reasons. WeChat is a widely used social software. To help users solve this problem, this article will introduce how to retrieve deleted contacts in a simple way. 1. Understand the WeChat contact deletion mechanism. This provides us with the possibility to retrieve deleted contacts. The contact deletion mechanism in WeChat removes them from the address book, but does not delete them completely. 2. Use WeChat’s built-in “Contact Book Recovery” function. WeChat provides “Contact Book Recovery” to save time and energy. Users can quickly retrieve previously deleted contacts through this function. 3. Enter the WeChat settings page and click the lower right corner, open the WeChat application "Me" and click the settings icon in the upper right corner to enter the settings page.

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Tomato Novel is a very popular novel reading software. We often have new novels and comics to read in Tomato Novel. Every novel and comic is very interesting. Many friends also want to write novels. Earn pocket money and edit the content of the novel you want to write into text. So how do we write the novel in it? My friends don’t know, so let’s go to this site together. Let’s take some time to look at an introduction to how to write a novel. Share the Tomato novel tutorial on how to write a novel. 1. First open the Tomato free novel app on your mobile phone and click on Personal Center - Writer Center. 2. Jump to the Tomato Writer Assistant page - click on Create a new book at the end of the novel.

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual

After some users have updated and upgraded the win11 system, the computer has no sound. The problem of loving you is usually caused by no device, missing sound card driver, or unknown error. So how should we solve these problems? , this issue of win11 tutorial is here to answer everyone’s questions. Next, let’s take a look at the detailed steps. Solution to no sound after win11 upgrade: 1. No device 1. If we are using a desktop computer, it is probably because there is no device. 2. Because ordinary desktop computers do not come with built-in speakers, we need to plug in speakers or headphones to have sound. 2. The sound card driver is missing 1. After we update the Win11 system, the original sound card or audio device driver may not be available.

The difference between Go language methods and functions lies in their association with structures: methods are associated with structures and are used to operate structure data or methods; functions are independent of types and are used to perform general operations.
