아래 쿼리를 통해, LogShipping Log 복원이 주 서버에서 언제 백업된 파일까지 복원했는지를 찾을 수 있다.
--
USE msdb
GO
/*2015-03-16 SQLDBWook@gmail.com / SQL Server 2012*/
--Primary 서버에서 대량의 트랜잭션이 발생한 이후,
-- LogShipping Secondary 서버의 IO병목등의 이유로 인해 Log복원 대기가 발생할 시
-- 현재까지 복원된 Log 중 최종 LogFile의 백업일시를 구한다.
DECLARE @vLogShippedDatabaseName sysname= N'trigger_sync_db_from_local_pcbang'
, @vDateChkVal char(2)= LEFT(YEAR(getdate()),2)
SELECT DATEADD( HOUR
,DATEDIFF(HOUR,GETUTCDATE(),GETDATE()) --Diff Hour With UTC Time
,CAST(
LEFT(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),4) + '-'
+ SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),5,2) + '-'
+ SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),7,2) + ' '
+ SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),9,2) + ':'
+ SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),11,2) + ':'
+ SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),13,2)
AS datetime
)
) LastRestoredLogBackupsBackupDate
--, LEFT(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),4) + '-'
-- + SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),5,2) + '-'
-- + SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),7,2) + ' '
-- + SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),9,2) + ':'
-- + SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),11,2) + ':'
-- + SUBSTRING(SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14),13,2)
--, SUBSTRING(last_restored_file,CHARINDEX(@vDateChkVal,last_restored_file,1),14)
, *
FROM msdb.dbo.log_shipping_secondary_databases
WHERE secondary_database =@vLogShippedDatabaseName
'MS SQL Server > Administration&Management' 카테고리의 다른 글
SQL Server 프로그래밍기능 파라미터 검색 쿼리 (0) | 2016.03.24 |
---|---|
tempdb 파일 삭제하기 (0) | 2016.03.20 |
Service Broker에서 수행하는 작업 모니터링(sp_broker_works) (0) | 2015.03.10 |
Server 레벨 계정 Role 및 권한 보기 (0) | 2015.02.02 |
sp_job (0) | 2014.11.19 |