Here is the solution provided by Patrick Flynn. Congratulations Patrick for being one of this weeks winners.
I really liked this solution for a number of reasons, first it showed how to pull data from DBCC Page and actually convert it into rows and columns that could then be inserted back into a table. Secondly due to its use of Common Table Expressions.
This was done using SQL Server 2014.
Approach used was:
(a) Restore and check database – Corruption is related to Allocation Meta Data for dbo.Customers
(b) Use the non-clustered indexes on FirstName and LastName to recover data apart from Middle name – Total of 511740 rows in Table
Steps are in CorruptionChallange Setup.sql (requires disabling Database triggers
(c) Cannot directly select data from pages due to allocation issues but can select raw data vis DBCC Page (and DBCC IND)
Requires using DBCC Ind to get list of Data pages and DBCC Page to extract data
Steps to extract and Parse data are in DBCCPage_Extract
Read More »Corruption Challenge 4 – Alternate Solution