问题描述
我正在使用以下代码检查我的数据库是否有任何问题/需要进行故障排除:
I am using the below code to check if my database has any issues/requires troubleshooting:
现在,DBCC CHECKDB
命令可能会产生如下结果:
Now, the DBCC CHECKDB
command might result in something like this :
CHECKDB 在数据库mydb"中发现 0 个分配错误和 15 个一致性错误
可以修复以下 SQL 查询:
Which can be fixed the following SQL query :
但是在通过我的应用程序执行以下查询之前,有没有办法知道 DBCC CHECKDB
是否真的返回了任何错误?因为没有任何错误,修复数据库就没用了...
But before executing the following query through my application, is there a way to know if DBCC CHECKDB
has really returned any errors at all ? Because without any errors, repairing the database will be useless...
有什么帮助吗?
一个让我心碎的想法
我正在考虑将字符串从 strBuilder
获取到文本框.将检查文本框是否可用以下行 CHECKDB 在数据库中发现 0 个分配错误和 15 个一致性错误...
I was thinking of getting the string from strBuilder
to a textbox.The textbox will be checked for the availability of the following line CHECKDB found 0 allocation errors and 15 consistency errors in database
..
但这仍然是不可能的,因为该行可能会不时不同.例如
But this is still not possible because that line can be different from time to time.E.g.
CHECKDB 发现 0 个分配错误和 15 个一致性错误
CHECKDB 发现 1 个分配错误和 14 个一致性错误
有更好的想法吗?
推荐答案
有多种可能性:
1.
添加NO_INFOMSGS
命令的选项.
这样,如果没有发现错误,就不会返回任何记录.
1.
Add NO_INFOMSGS
option to the command.
Like this, no records will be returned if no errors are found.
<小时>
2.
读取Level
列的值.如果大于10
,则发生错误.(参考)
您可以获得的 DBCC 错误列表:
2.
Read the value(s) of column Level
. If one is higher than 10
, an error occured. (Reference)
A list of the DBCC-errors you can get with:
<小时>
3.
检查结果字符串中是否有大于 0
的数字.
这篇关于DBCC CheckDb-vb.net 有什么检测错误的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!