Wednesday, March 7, 2012

Restore nText from Transaction Log

A user of mine deleted a chunk of data from one of our databases that
was, unfortunately, not properly backed up. I have captured the
transaction log and using ApexSQL Log I am able to view all of the
delete statements. ApexSQL Log generates undo scripts for these
deletes, but there is an issue...
The deleted records contained nText fields. In the transaction log,
these are logged as hex values and thus can't be reassigned to the
nText fields. Any operation I can perform to turn the data in the
transaction log (i.e. 0x0000ad2400000000fa12000001000100) into the
original nText?Derek wrote:
> A user of mine deleted a chunk of data from one of our databases that
> was, unfortunately, not properly backed up. I have captured the
> transaction log and using ApexSQL Log I am able to view all of the
> delete statements. ApexSQL Log generates undo scripts for these
> deletes, but there is an issue...
> The deleted records contained nText fields. In the transaction log,
> these are logged as hex values and thus can't be reassigned to the
> nText fields. Any operation I can perform to turn the data in the
> transaction log (i.e. 0x0000ad2400000000fa12000001000100) into the
> original nText?
I would check with Apex Software to see what they say. If the text
involved is less than 4,000 bytes, you can probably cast the value back
to a nvarchar. For example:
SELECT CAST(N'ABC123' as VARBINARY(100)) -- 0x410042004300310032003300
SELECT CAST(0x410042004300310032003300 as NVARCHAR(4000)) -- ABC123
David Gugick
Quest Software
www.imceda.com
www.quest.com

No comments:

Post a Comment