Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

T-SQL Tuesday #86 Adding when DBCC CHECKDB last ran to the SYS.DATABASES cata ...

$
0
0

T-SQL Tuesday #86   Adding when DBCC CHECKDB last ran to the SYS.DATABASES cata ...
SQLvariant T-SQL Tuesday #86 Adding when DBCC CHECKDB last ran to the SYS.DATABASES catalog view Posted on 10 January 2017 Comments Brent Ozar is hosting TSQL2sDay #86 this month and in response to Brent Ozar’s Call for Important Connect Items I wanted to highlight this one about adding the date of the last known good DBCC CHECKDB to SYS.DATABASES. This one seems like a no-brainer to me. When you NEED this information, you don’t want to have to go hunting for it, and ever Microsoft agreed: “Posted by Sunil [MSFT] on 8/20/2008 at 11:05 AM This issue has been approved/fixed and should be available in a future release of SQL Server. Thanks for providing us your feedback to SQL Server. ” https://connect.microsoft.com/SQLServer/feedback/details/350596/ Adding when DBCC CHECKDB last ran to the SYS.DATABASES catalog view Description Currently it is not easy to determine when DBCC CHECKDB last ran successfully on a database. Of if you like when it last ran and the state value of that execution in the case of a failure. (The state values that are discussed in BOL at http://msdn.microsoft.com/en-us/library/ms176064.aspx) Sure the information is written to the error log. You can also examine the dbi_dbccLastKnownGood value in page 9 of the database. But it should be easier to get this critical information. The Good News: The good news is that someone Sankar Reddy figured out an easy way how to do it and posted their query in the comments on the Connect Item: CREATE TABLE #temp (Id INTIDENTITY(1,1), ParentObject VARCHAR(255), [Object] VARCHAR(255), Field VARCHAR(255), [Value] VARCHAR(255) ) INSERT INTO #temp EXECUTE SP_MSFOREACHDB‘DBCC DBINFO ( ”?”) WITH TABLERESULTS’; ;WITH CHECKDB1 AS ( […]

Viewing all articles
Browse latest Browse all 3160

Trending Articles