Aug 282015 Posted in Community, Corruption, DBCC, Scripts0 Responses

Data Recovery and Fixing Database Corruptions @DBA Lounge

I had recently presented to local DBA and Developers community in Iasi (Romania), a session on database corruptions and data recovery techniques in SQL Server.
It was interesting to discuss pros and cons of the approaches used in the demo, root causes for the corruptions, finding differences and correspondences Microsoft SQL Server vs. Oracle.
This was a touching base with Microsoft SQL Server storage internals and in the same time a “deep dive” into what can be done in order to protect/recover data.

The DBA Lounge group started few years ago on Linkedin, as we wanted to know each other better, share knowledge and have fun. The community is no technology specific. Anyone interested in database systems is welcomed.


Read More…

Jun 032015 Posted in Corruption, Scripts0 Responses

Convert LSN to Numeric

As part of the Database Corruption Challenge I needed to convert the LSN values returned by fn_dblog() / fn_dump_dblog() to numeric.

The math is not very simple and it is best described by Paul Randal.

  • Take the rightmost 4 characters (2-byte log record number) and convert to a 5-character decimal number, including leading zeroes, to get stringA
  • Take the middle number (4-byte log block number) and convert to a 10-character decimal number, including leading zeroes, to get stringB
  • Take the leftmost number (4-byte VLF sequence number) and convert to a decimal number, with no leading zeroes, to get stringC
  • The LSN string we need is stringC + stringB + stringA

Read More…