WHEN DATABASE CORRUPTION STRIKES Presented by Steve Stedman Founder/Owner of Stedman Solution, LLC.

Slides:



Advertisements
Similar presentations
10 Things Not To Do With SQL SQLBits 7. Some things you shouldn’t do.
Advertisements

SQL Server Best Practices Keep Your Database In Top Performance Shape and Maintain Effective Backups September, 2007 Richard Kokoski.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Brian Alderman | MCT, CEO / Founder of MicroTechPoint Pete Harris | Microsoft Senior Content Publisher.
RMAN Restore and Recovery
Backup and Recovery Part 1.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
Database Configuration and Maintenance Database Configuration and Maintenance Exam / 30.
Transaction log grows unexpectedly
Today’s Agenda Chapter 12 Admin Tasks Chapter 13 Automating Admin Tasks.
Administration etc.. What is this ? This section is devoted to those bits that I could not find another home for… Again these may be useless, but humour.
ApexSQL Log Recover accidentally truncated, dropped or deleted data with or without transaction log or its backup. Recover data from un-attachable/corrupted.
Monday, 13 October 2003 The Anatomy of a Data Modification Subset of: What everyone should know about Performance, Recovery & Logging Monday, 13 October.
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
Rajib Kundu Agenda Definitions Failover Cluster Database Snapshots Log shipping Database Mirroring.
Reliability and Security in Database Servers By Samuel Njoroge.
Learningcomputer.com SQL Server 2008 – Administration, Maintenance and Job Automation.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Page 1 SQL Server Myths XV ENCONTRO DA COMUNIDADE SQLPORT Rui Ribeiro MCITP 2011/08/16.
1 Copyright © 2004, Oracle. All rights reserved. Introduction.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
Module 16: Performing Ongoing Database Maintenance
Oracle Database 10 g Time Navigation: Human-Error Correction Magnus Lubeck DBA/Systems Analyst CERN, IT-DB Group Session id: Tammy Bednar Sr. Product.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
A Brief Documentation.  Provides basic information about connection, server, and client.
Week 7 : Chapter 7 Agenda SQL 710 Maintenance Plan:
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
1 Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 15: Reliability and Security in Database Servers Instructor’s.
Save Money by Supporting Yourself Presented By: Cale Tanguay CPA CGA.
IT1001 – Personal Computer Hardware & system Operations Week7- Introduction to backup & restore tools Introduction to user account with access rights.
Chapter 15: Reliability and Security in Database Servers Neyha Amar CS 157B May 6, 2008.
© 2006 Northgate Information Solutions plc and its associated companies. All rights reserved. Slide 1.
Keeping your Data Repository in Top Health By: Ian Proffer MUSE Session 359.
Step 1of 11 Admin Demonstrations Click Here to Start.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
Digging Out From Corruption Eddie Wuerch, MCM - Principal, Database Performance - Salesforce Marketing Cloud Data protection and loss recovery with SQL.
SQL SERVER MAINTENANCE PLANS Kat
# CCNZ What is going on here???
Linkedin: dennisegraham Dennis E Graham Reporting For SQL Health.
Microsoft SQL is known as RDMS (Relational Database Management System) which is developed by Microsoft and is highly used at corporate and enterprise.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
Dealing with Database Corruption DBA 911. Who am I? 2 David M Maxwell twitter.com/dmmaxwell or twitter.com/upsearchsqltwitter.com/dmmaxwelltwitter.com/upsearchsql.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
Database Administration
You Inherited a Database Now What?
Curacao SQL Saturday June 11, 2016
Database Corruption Advanced Recovery Techniques|
Designing Database Solutions for SQL Server
Introduction to SQL Server Management for the Non-DBA
Warner Chaves MCM / MVP / SQLTurbo.com / Pythian.com
Database Administration for the Non-DBA
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Database Corruption Advanced Recovery Techniques
Understanding and Handling Database Corruption
Backup and Restore your SQL Server Database
TechEd /24/2018 8:21 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Database Corruption Advanced Recovery Techniques
TEMPDB – INTERNALS AND USAGE
Database Corruption Advanced Recovery Techniques
Warner Chaves MCM / MVP / SQLTurbo.com / Pythian.com
Warner Chaves MCM / MVP / SQLTurbo.com / Pythian.com
Making PowerShell Useful
You Inherited a Database Now What?
Performing Database Recovery
Advanced Recovery Techniques
Managing the mystery database
Managing the mystery database
Presentation transcript:

WHEN DATABASE CORRUPTION STRIKES Presented by Steve Stedman Founder/Owner of Stedman Solution, LLC.

About Steve Founder of the Database Corruption Challenge Author SQL Server – Common Table Expressions Book Creator of Database Health Monitor ( 25 years of SQL Server experience Freelance Database Consultant (SQL Server) looking for contract DBA, remote DBA, or part time DBA work.

Agenda Detecting Corruption Tracking Corruption (what has gone bad?) Before fixing or removing corruption Removing Corruption Examples

Detecting Corruption DBCC CheckDB

Detecting Corruption DBCC CheckDB DBCC CheckTable

Detecting Corruption DBCC CheckDB DBCC CheckTable DBCC Check_____ Constraints, Catalog, Alloc, FileGroup, Ident

Detecting Corruption DBCC CheckDB DBCC CheckTable DBCC Check_____ Constraints, Catalog, Alloc, FileGroup, Ident msdb..suspect_pages

Detecting Corruption DBCC CheckDB DBCC CheckTable DBCC Check_____ Constraints, Catalog, Alloc, FileGroup, Ident msdb..suspect_pages Just running a query may show corruption.

Tracking Corruption (what has gone bad?) Error Messages and the Error Log

Tracking Corruption (what has gone bad?) Error Messages and the Error Log See what you can query -- lets see what we have in the corrupt table SELECT * FROM Revenue; rows

Tracking Corruption (what has gone bad?) Error Messages and the Error Log See what you can query Check your non-clustered indexes -- pull from the non-clustered index without -- touching the clustered index SELECT [id], [DepartmentID], [Revenue] FROM Revenue WITH (INDEX (ncDeptIdYear) );

Before Fixing or Removing Corruption Do you have a way to undo, or start over if something goes wrong? Do you have a backup of the current state? What if you go through the whole process, but determine that part of your cleanup dropped a row that could have been saved in the beginning. Can you go back and do it again?

Removing Corruption Drop/Recreate Index – if corruption is in a non-clustered index Truncate table – if you have a way to get the contents back DBCC CheckTable(Revenue, REPAIR_REBUILD); DBCC CheckTable(Revenue, REPAIR_ALLOW_DATA_LOSS); DBCC CheckDB(database1, REPAIR_ALLOW_DATA_LOSS); Less conventional methods – test server, not production Edit the database file with a hex-editor -- WARNING Danger!!! DBCC WritePage -- WARNING Danger!!!

Example 1 You are given a.bak file with a corrupt database. That’s it… That is all you have access to. The original database was already destroyed by a network admin attempting to solve the problem.

Example 1 – DBCC CheckDB

Stop - Think What would I do first? If my work makes something worse, how can I undo what I try? What can I do to determine what is corrupt? What can I do to recover missing data caused by the corruption? Demo: Example 1

Example 2 The story… A backup was run yesterday, after that backup several changes were made to the database, inserts deletes, updates, and more. Sometime today corruption was encountered when someone attempted to run the following query: SELECT * FROM Revenue;

Example 2 – Additional Details You have two backups, the latest is a backup of the current corrupt database. The Two Days Ago Backup is the only other backup file available, and it does not contain any corruption.

Example 2 - Errors

Stop - Think What would I do first? If my work makes something worse, how can I undo what I try? What can I do to determine what is corrupt? What can I do to recover missing data caused by the corruption? Demo: Example 2

Example 3 - Timeline 2:53pm - full backup 2:54pm - transaction log backup 3:01pm - transaction log backup 3:12pm - transaction log backup 3:19 a catastrophic failure occurred causing the operating system running SQL Server to reboot. Let’s blame it on a power surge, or maybe it was just someone who accidently bumped the power cord. I like the power surge idea, so that I don’t get blamed for kicking the power cord.

Example 3 After the server rebooted, several other databases on this SQL Server recovered just fine, however the CorruptionChallenge3 database would not come on line. After examining the SQL Server data directory, it was discovered that the.mdf file for this database was gone. The only thing that remained on this SQL Server was the.ldf file and previous backups for this database. The database is in the Recovery Pending state.

Stop - Think What would I do first? If my work makes something worse, how can I undo what I try? What can I do to determine what is corrupt? What can I do to recover missing data caused by the corruption? Demo: Example 3

Example 4 The database name is [CorruptionChallenge4], it was created and backed up on SQL Server 2008R2. Sorry, no SQL Server 2005 support due to features in the challenge that didn’t exist in SQL Server 2005 (perhaps that a hint). Here is what we know: Everything was just fine, and all of a sudden users started reporting the following error when selecting from the database.

Summary Detecting Corruption Tracking Corruption (what has gone bad?) Before fixing or removing corruption Removing Corruption Examples

More Examples More Corruption Challenges available on my website. Week 5 – Challenge currently running My website: Connect LinkedIn