DECLARE @db_name TABLE
(
db_name_ID int identity,
DBName sysname
);
DECLARE @objects TABLE
(
db_name sysname,
ob_name sysname,
type nvarchar(60),
date datetime,
s_name sysname
);
DECLARE @cnt int;
DECLARE @DBName sysname;
INSERT INTO @db_name
(DBName)
VALUES ('Your_Database_Name')
-- OR SELECT name FROM sys.databases WHERE database_id <> 2;
SELECT @cnt = COUNT(*) FROM @db_name;
WHILE @cnt > 0
BEGIN
SELECT @DBName = DBName FROM @db_name WHERE db_name_ID = @cnt;
INSERT INTO @objects
exec('use ['+@DBName+']; SELECT '''+@DBName+''' as db_name,o.name as object_name,o.type_desc, o.modify_date, s.name as schema_name from sys.all_objects o left outer join sys.schemas s
on (o.schema_id = s.schema_id) where modify_date > ( GETDATE() -3000);');
SET @cnt = @cnt-1;
END
SELECT *
FROM @objects
--where ob_name = 'Your_Object_Name'
ORDER BY date desc, db_name, s_name, ob_name;
No comments:
Post a Comment