The script provided below, shows every modified and created events in the last 7 days.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 'modify' as [Action], db_name() as db,name,modify_date,create_date | |
INTO #eachdb | |
FROM sys.objects | |
WHERE 0=1 | |
declare @str varchar(8000) | |
set @str = 'USE [?] | |
INSERT INTO #eachdb | |
SELECT ''modify'' as [Action], db_name() as db,name,modify_date,create_date | |
FROM [?].sys.objects | |
WHERE type = ''P''AND | |
DATEDIFF(D,modify_date, GETDATE()) < 7 | |
—-Change 7 to any other day value. | |
UNION ALL | |
SELECT ''create''as [Action],db_name() as db ,name,modify_date,create_date | |
FROM [?].sys.objects | |
WHERE –type = ''P''AND | |
DATEDIFF(D,create_date, GETDATE()) < 7 | |
—-Change 7 to any other day value. | |
ORDER BY 3 DESC, 4 DESC | |
' | |
exec sp_MSforeachdb @str | |
Select * | |
from #eachdb | |
where db <> 'tempdb' | |
order by 3,4,5 | |
drop table #eachdb |