标签:sele not sys sel databases bsp master user base
P.S when restart sql server, it will reset all data
select d.name, x1 =
(select X1 = max(bb.xx)
from (
select xx = max(last_user_seek)
where max(last_user_seek) is not null
union all
select xx = max(last_user_scan)
where max(last_user_scan) is not null
union all
select xx = max(last_user_update)
where max(last_user_update) is not null
) bb
)
from master.dbo.sysdatabases d
left outer join sys.dm_db_index_usage_stats s
on d.dbid = s.database_id
group by d.name
select d.name,
last_user_seek = max(last_user_seek),
last_user_scan = max(last_user_scan),
last_user_update = max(last_user_update),
last_user_lookup = max(last_user_lookup)
from sys.dm_db_index_usage_stats as i
join sys.database as d on i.database_id = d.database_id
group by d.name
标签:sele not sys sel databases bsp master user base
原文地址:https://www.cnblogs.com/gupen/p/10320897.html