摘要:
-- Find DBs that have not been backed up in last 24 hourSELECT name AS database_name , backup_finish_date , coalesce(type,'NO BACKUP') AS last_backup_typeFROM( SELECT database_name,backup_finish_date, CASE WHEN type = 'D' THEN 'Full' WHEN type = 'I' THEN 'Differen 阅读全文
摘要:
SET NOCOUNT ONDECLARE @c INTDECLARE @failed_jobs TABLE ( job_id uniqueidentifier, step_id int, step_name sysname, sql_message_id int, sql_severity int, message nvarchar(1024), run_status int, FailureDate datetime, server nvarchar(30))INSERT @failed_jobs(job_id, step_id, step_name, sql_message_id, sq 阅读全文
摘要:
--得到最耗时的前N条T-SQL语句 --适用于SQL SERVER 2005及其以上版本 --给N赋初值为30 declare @n int set @n=30;with maco as (select top (@n) plan_handle, sum(total_worker_time) as total_worker_time , sum(execution_count) as execution_count , count(1) as sql_count from sys.dm_exec_query_stats group by plan_handle order by sum(t. 阅读全文