2012-12-26

Silinen Bir SQL Modülünün Kodunu Geri Kurtarma

İki tarih arasında sildiğiniz trigger, stored procedure, view, function'ın kodunu aşağıdaki T-SQL kodu ile alabilirsiniz:

declare @StartDate Datetime='2012-01-01',
@EndDate Datetime='2013-01-01'

select convert(varchar(max),substring([rowlog contents 0],33,len([rowlog contents 0]))) as [script]
from fn_dblog(null,null)
where [operation]='lop_delete_rows' and [context]='lcx_mark_as_ghost'
and [allocunitname]='sys.sysobjvalues.clst'
and [transaction id] in (select distinct [transaction id] from    sys.fn_dblog(null, null)
where context ='LCX_NULL'
and operation ='LOP_BEGIN_XACT'
and [transaction name]='DROPOBJ'
and  convert(nvarchar(11),[Begin Time]) between @StartDate AND @EndDate)
and substring([RowLog Contents 0],33,len([RowLog Contents 0]))<>0

Not: T-SQL kod SQL Server 2012 ile test edildi.

.::YASAL UYARI::.

©2004-2023 Mehmet GÜZEL, www.mehmetguzel.net

Site içeriği kaynak gösterilmek koşuluyla yayınlanabilir. Yazılan yazı ve yorumlar sadece yazı ve yorum sahiplerini bağlar.