日期:2014-05-18 浏览次数:20597 次
if object_id('tempdb..#') Is not null Drop Table # Create table #(dbname sysname,LastModifyDate datetime) Insert Into # Exec sys.sp_MSforeachdb 'Select ''?'', max(modify_date) From ?.sys.objects' Select * from # Order by LastModifyDate Desc
------解决方案--------------------
declare @T table(DBName sysname,modify_date datetime) insert @T exec sp_msforeachdb 'select ''?'',max(modify_date) from ?.sys.objects' select * from @T
------解决方案--------------------
exec sp_msforeachdb 'use [?]if ''?'' not in(''master'', ''model'', ''msdb'', ''tempdb'' ) select ''[?]'',max(modify_date) from sys.objects '
------解决方案--------------------
create table #tb(dbname varchar(50),date datetime) insert into #tb exec sp_msforeachdb 'select ''?'' as dbname,max(modify_date) as date from ?.sys.objects' select * from #tb drop table #tb