如何在sql server 2008中查找最近9天创建和修改的表 [英] how to find last 9 days create and modified tables in sql server 2008
本文介绍了如何在sql server 2008中查找最近9天创建和修改的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在SQL Server 2008中查找创建和修改表的最近9天活动。
请帮助我,紧急。
解决方案
SELECT * FROM sys.tables
WHERE type = ' U' AND
create_date> ' 2015-06-03 00:00:00.000' 或 - 提供您的日期
modify_date> ' 2015-06-03 00:00:00.000' - 提供您的日期
谢谢
Bimal
请参阅此CP文章: SQL Server:搜索存储过程使用T-SQL创建/修改日期或文本 [ ^ ]
2008年之前你可以使用SELECT * FROM sys.tables
其中 create_date> = DATEADD(DAY,-9,dateadd(dd,datediff(dd, 0 ,GETDATE()) , 0 ))
或 mo dify_date> = DATEADD(DAY,-9,dateadd(dd,datediff(dd, 0 ,GETDATE()), 0 ))
您现在可能应该使用SELECT *
FROM INFORMATION_SCHEMA.TABLES IS_T
INNER JOIN sysobjects so ON IS_T。[TABLE_NAME] = so。[name]
其中 crdate> = DATEADD(DAY,-9,dateadd(dd,datediff(dd, 0 ,GETDATE()), 0 ))
或 refdate> = DATEADD(DAY,-9,dateadd(dd,datediff(dd, 0 ,GETDATE()), 0 ))警告 - 我是不相信
refdate
实际上是最后一次修改日期 - 你需要进一步研究
注意我用日期做的事情 - 这样比较是基于当天的开始而不是查询运行的时间。
How to find last 9 days activity for create and modified tables in SQL Server 2008.
Please help me, its urgent.
解决方案
Hi,
SELECT * FROM sys.tables WHERE type='U' AND create_date > '2015-06-03 00:00:00.000' OR -- Provide your date modify_date > '2015-06-03 00:00:00.000' -- Provide your date
Thanks
Bimal
See this CP article: SQL Server: Search Stored Procedure Create/Modify Date or Text using T-SQL[^]
Prior to 2008 you could useSELECT * FROM sys.tables where create_date >= DATEADD(DAY, -9, dateadd(dd, datediff(dd, 0, GETDATE()), 0)) or modify_date >= DATEADD(DAY, -9, dateadd(dd, datediff(dd, 0, GETDATE()), 0))
Potentially you should now useSELECT * FROM INFORMATION_SCHEMA.TABLES IS_T INNER JOIN sysobjects so ON IS_T.[TABLE_NAME] = so.[name] where crdate >= DATEADD(DAY, -9, dateadd(dd, datediff(dd, 0, GETDATE()), 0)) or refdate >= DATEADD(DAY, -9, dateadd(dd, datediff(dd, 0, GETDATE()), 0))Caveat - I'm not convinced that
refdate
is actually the last amended date - you will need to research further
Note the stuff I've done with the date - that is so that the comparison is based on the beginning of the day instead of the time of day that the query is run.
这篇关于如何在sql server 2008中查找最近9天创建和修改的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文