上次修改日期对象

发布于 2024-07-06 10:57:13 字数 166 浏览 9 评论 0原文

如何找出 MS SQL Server 2000 对象的最后修改日期?

我需要获取自 8 月 15 日以来修改的所有视图、过程、函数等的列表。 在 sysObjects 中,我可以看到对象的创建日期,但我需要知道它们上次更改的时间。

注意:这是一个 SQL 2000 数据库。

How can I find out the date a MS SQL Server 2000 object was last modified?

I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered.

NB: this is an SQL 2000 database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浮生面具三千个 2024-07-13 10:57:13

我知道这有点旧,但是可以使用此查询查看存储的过程和函数的最后更改日期:

USE [Your_DB]    
SELECT * FROM INFORMATION_SCHEMA.ROUTINES

只是认为提及这一点会很好,因为我搜索了这个解决方案这条线索具有误导性。

I know this is a bit old, but it is possible to view the last altered date of stored procs and functions with this query:

USE [Your_DB]    
SELECT * FROM INFORMATION_SCHEMA.ROUTINES

Just thought it would be nice to mention this since I searched for this very solution and this thread was misleading.

落花随流水 2024-07-13 10:57:13

我已通过以下查询得到上述任何过程修改日期历史记录的确认答案

上执行该过程

SELECT name, create_date, modify_date 
FROM sys.objects
WHERE type = 'p' 

步骤 -1 在数据库步骤 -2
然后将文本复制到 Excel,并带有标题

选择路径列,然后将确切的过程名称粘贴到 ^F 窗口中,然后按 Enter
您将获得准确的修改日期。

问候,
苏迪尔
浦那

I have got confirmed Answer for above any procedure History for modified date with below query

Step -1 Execute the procedure on DB

SELECT name, create_date, modify_date 
FROM sys.objects
WHERE type = 'p' 

Step -2
Then copy the text to Excel with headers

select route coloumn and then paste the exact procedure name into ^F window and press enter
you will get exact modified date.

Regards,
Sudhir
Pune

吹泡泡o 2024-07-13 10:57:13

请注意,SQL Server 实际上记录最后修改日期。 它不存在于任何系统表中。

架构更改历史记录报告实际上是根据默认跟踪构建的。 由于许多管理员(和网络主机)将其关闭,因此它可能不适合您。
Buck Woody 很好地解释了此报告的工作原理 此处。 数据也是临时的。

因此,您永远不应该依赖架构更改历史记录报告。 替代方案:

  • 使用 DDL 触发器 将所有架构修改记录到您的表中选择。
  • 执行一个协议,其中视图和过程永远不会改变,它们只会被删除和重新创建。 这意味着创建日期也将是最后更新日期(这显然不适用于表)。
  • 在源代码管理中警惕地对 SQL 对象和架构进行版本控制。

--

编辑:看到这是 SQL 2000。这排除了默认跟踪和 DDL 触发器。 您只剩下我上面列出的更乏味的选项之一。

Note that SQL Server actually does not record the last modification date. It does not exist in any system tables.

The Schema Changes History report is actually constructed from the Default Trace. Since many admins (and web hosts) turn that off, it may not work for you.
Buck Woody had a good explanation of how this report works here. The data is also temporary.

For this reason, you should never RELY on the Schema Changes History report. Alternatives:

  • Use DDL Triggers to log all schema modification to a table of your choosing.
  • Enforce a protocol where views and procs are never altered, they are only dropped and recreated. This means the created date will also be the last updated date (this does not work with tables obviously).
  • Vigilantly version your SQL objects and schema in source control.

--

Edit: saw that this is SQL 2000. That rules out Default Trace and DDL Triggers. You're left with one of the more tedious options I listed above.

云淡风轻 2024-07-13 10:57:13

这并不总是正确的,因为修改日期是上次使用 ALTER 语句修改对象的日期。 如果对象是表或视图,则在创建或更改表或视图上的聚集索引时,modify_date 也会更改。

This is not always correct because modify_date is Date the object was last modified by using an ALTER statement. If the object is a table or a view, modify_date also changes when a clustered index on the table or view is created or altered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文