如何查询SQL Server 2005中子报表的状态

时间:2015-01-14 14:27:19

标签: sql sql-server

我正准备升级SQL Server 2005的实例。此实例还处理一些需要移动的报告。我试图找出哪些报告不再被使用(截至过去14个月),以便它们可以退役。我一直在使用以下查询,它返回报告的名称,但似乎缺少子报告。有谁知道更好的方法?任何帮助将非常感激。查询如下:

USE ReportingServicesExecutionLog;
GO

WITH FindUsedReports AS 

(SELECT DISTINCT r.name AS [Name], 
             MAX(e.timeend) AS [Date Last Used],
             COUNT(e.ExecutionLogID) AS [Number of Times Used],
             rt.Name AS [Report Type],
             u.UserName AS [User Name],
             r.path AS [Path]
FROM dbo.Reports r
    INNER JOIN dbo.ExecutionLogs e
           ON r.ReportKey=e.ReportKey
    INNER JOIN ReportTypes rt
           ON r.ReportType=rt.ReportType
    INNER JOIN dbo.Users u
           ON e.UserKey=u.UserKey
GROUP BY r.name, u.UserName, rt.Name, r.path
)

SELECT * 
FROM FindUsedReports
WHERE [Date Last Used] <= DATEADD(mm,-14, GETDATE())
ORDER BY [Name];

0 个答案:

没有答案