Database Corruption Week 1 Solution

Database Corruption Week 1 Solution

Here is my solution for week one. The original database and detailsĀ for this can be found here:

http://stevestedman.com/2015/04/introducing-the-database-corruption-challenge-dbcc-week-1-challenge/

USE [CorruptionChallenge1]
GO
SELECT [id],[Notes] INTO #s FROM [dbo].[Revenue] s WITH (INDEX([ncBadNameForAnIndex]))
GO
DBCC DBREINDEX ('dbo.Revenue',clustId);
GO
UPDATE t SET t.[Notes] = s.[Notes] FROM [dbo].[Revenue] t
INNER JOIN #s s ON t.[id] = s.[id] WHERE t.[Notes] <> s.[Notes] OR t.[Notes] IS NULL
GO
SELECT * FROM [dbo].[Revenue]
GO
DROP TABLE #s
GO
DBCC CHECKDB('CorruptionChallenge1') WITH NO_INFOMSGS,ALL_ERRORMSGS;
GO

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *