如何在SQL Server中检查存储过程或函数中最后一次更改的date
我需要检查上次更改函数的时间。 我知道如何检查创builddate(它在SQL Server Management Studio中的函数属性窗口中)。
我发现在SQL Server 2000中无法检查修改date(看这篇文章: 是否有可能确定存储过程最后在SQL Server 2000中进行了修改? )
是否有可能在SQL Server 2008中检查它? MS是否在系统表中增加了一些新function,以便检查?
SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'P'
程序的type
是FN
而不是P
或者你可以过滤名称列。
你有没有尝试过:
SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'P' AND name = 'myProc'
这是正确的解决scheme。
SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'fn' AND name = 'fn_NAME'
对于SQL 2000,我将使用:
SELECT name, crdate, refdate FROM sysobjects WHERE type = 'P' ORDER BY refdate desc
我刚刚发现,这被列为新技术
这是非常详细的
SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = N'PROCEDURE' and ROUTINE_SCHEMA = N'dbo' order by LAST_ALTERED desc SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = N'PROCEDURE' and ROUTINE_SCHEMA = N'dbo' order by CREATED desc SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = N'FUNCTION' and ROUTINE_SCHEMA = N'dbo' order by LAST_ALTERED desc SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = N'FUNCTION' and ROUTINE_SCHEMA = N'dbo' order by CREATED desc
在最新版本(2012年或更多),我们可以通过使用此查询获取修改的存储过程的详细信息
SELECT create_date, modify_date, name FROM sys.procedures ORDER BY modify_date DESC
SELECT * FROM sys.objects WHERE type IN ('FN', 'IF', 'TF') AND name = 'dgdsgds'