Sie sind auf Seite 1von 2

xp_fixeddrives

go
sp_helpdb
go
select * from sys.sysprocesses where blocked != 0
go
dbcc sqlperf (logspace)
go
with Broken_Step(JobID, Stat, StepID, StepName, Msg, SDate, STime)
as
(
select job_id, run_status, step_id, step_name, [message], run_date, run_time
from msdb.dbo.sysjobhistory
where step_id != 0
and run_status != 1
)
select B.[name], A.run_date, A.run_time
, (case A.run_status when 1 then 'Succeeded' when 2 then 'Retry' when 3 then '
Canceled'
when 4 then 'In Progress' else 'Failed' end) as 'Status'
, A.run_duration
, (case when A.run_status != 1 then A.[message] else null end) as 'Job Outcome
'
, C.StepID, C.StepName as 'Failing Step', C.Msg as 'Step Outcome'
from msdb.dbo.sysjobhistory A
left join msdb.dbo.sysjobs B on B.job_id = A.job_id
left join Broken_Step C on C.JobID = A.job_id and C.Stat = A.run_status and
C.SDate = A.run_date and C.STime = A.run_time
where A.run_date > convert(char(8), getdate() - 2, 112)
and A.step_id = 0
order by run_date desc, run_time desc
/* returns in one row number of days/hours since last full/diff or transactional
backup for each db on the server */
/* also returns data on user dbs not backed up */
declare @Server varchar(40)
set @Server = CONVERT(varchar(35), SERVERPROPERTY('machinename'))+'\'+isnull(CON
VERT(varchar(35), SERVERPROPERTY('instancename')),'DEFAULT')
--full backups
SELECT @Server,
fullrec.database_name,
datediff(dd,fullrec.backup_finish_date,getdate()) as 'FullDays',
fullrec.backup_finish_date as 'FullFinish',
datediff(dd,diffrec.backup_finish_date,getdate()) as 'DiffDays',
diffrec.backup_finish_date as 'DiffFinish',
Case
when diffrec.backup_finish_date is NULL then NULL
else datediff(dd,fullrec.backup_finish_date,diffrec.backup_finish_date)
end as 'DaysBetwix',
datediff(hh,tranrec.backup_finish_date,getdate()) as 'TranHours',
tranrec.backup_finish_date as 'TranFinish'
FROM msdb..backupset as fullrec
left outer join msdb..backupset as tranrec
on tranrec.database_name = fullrec.database_name

and tranrec.type = 'L'


and tranrec.backup_finish_date =
((select max(backup_finish_date)
from msdb..backupset b2
where b2.database_name = fullrec.database_name
and b2.type = 'L'))
left outer join msdb..backupset as diffrec
on diffrec.database_name = fullrec.database_name
and diffrec.type = 'I'
and diffrec.backup_finish_date =
((select max(backup_finish_date)
from msdb..backupset b2
where b2.database_name = fullrec.database_name
and b2.type = 'I'))
where fullrec.type = 'D' -- full backups only
and fullrec.backup_finish_date =
(select max(backup_finish_date)
from msdb..backupset b2
where b2.database_name = fullrec.database_name
and b2.type = 'D')
and fullrec.database_name in (select name from master..sysdatabases)
and fullrec.database_name not in ('tempdb','pubs','northwind','model')
-- never backed up
Union all
select @Server
,name --, '**** ','Red',
,9999,'1900-01-01 00:00:00',
NULL, NULL , NULL, NULL, NULL
from master..sysdatabases as record
where name not in (select distinct database_name from msdb..backupset)
and name not in ('tempdb','pubs','northwind','model')
order by 1,2

Das könnte Ihnen auch gefallen