5

嗨,我正在尝试制作一份报告,其中列出了我们报告服务器上的所有订阅、它们所在的报告、它们运行的​​时间和日期以及重复。到目前为止,我已经能够获得报告的列表和报告的时间表。我似乎无法理解 Schedule 表中的值和列的含义。

如果有人能阐明如何理解这些列及其价值,我将不胜感激。这是我到目前为止的查询。

使用报告服务器;

SELECT Users.UserName
, c.Name AS Report
, Subscriptions.Description
, Schedule.*
/* , Schedule.RecurrenceType
, Schedule.MinutesInterval
, Schedule.DaysInterval
, Schedule.WeeksInterval
, Schedule.DaysOfWeek
, Schedule.DaysOfMonth
, Schedule.[Month]
, Schedule.MonthlyWeek */
FROM [Catalog] AS c
INNER JOIN Subscriptions
ON c.ItemId = Subscriptions.Report_OId
INNER JOIN Users
ON Subscriptions.OwnerId = Users.UserId INNER JOIN Schedule ON ReportSchedule.ScheduleId = Schedule.ScheduleId
INNER JOIN ReportSchedule
ON Subscriptions.SubScriptionId = ReportSchedule.SubScriptionId

谢谢,
克里斯

4

2 回答 2

1

我有一个解决方案,因为它出现在我正在写的报告中。

create function [dbo].[calendarlist](@Value_in as int,@Type as int) returns varchar(200)
as
begin

/*
This code is to work out either the day of the week or the name of a month when given a value
Wrriten by S Manson.
31/01/2012
*/

declare @strings as varchar(200)
declare @Count int

if @Type = 2    --Months
    Begin
        set @Count =12
    end
else if @Type = 1   --Days of Week
    Begin
        Set @Count = 7
    End
else    --Days of Month
    Begin
        Set @Count = 31
    End

set @strings = ''

while @Count<>0
begin
    if @Value_in>=(select power(2,@count-1))
        begin
            set @Value_in = @Value_in - (select power(2,@count-1))
            If @Type=2
                Begin
                    set @strings = (SELECT DATENAME(mm, DATEADD(month, @count-1, CAST('2008-01-01' AS datetime)))) + ',' + @strings
                end
            else if @Type = 1
                begin
                    set @strings = (SELECT DATENAME(dw, DATEADD(day, @count-1, CAST('2012-01-01' AS datetime)))) + ',' + @strings
                end
            else
                begin
                    set @strings = convert(varchar(2),@Count) + ', ' + @strings
                end

        end
    set @count = @count-1
end
if right(@strings,1)=','
    set @strings = left(@strings,len(@strings)-1)

return @strings

end
于 2012-01-31T08:42:32.580 回答
1

这是部分答案...

DaysOfWeek 与二进制设置有关,其中:

星期日是位 0:值 1 星期一是位 1:值 2 星期二是位 2:值 4 星期三是位 3:值 8 星期四是位 4:值 16 星期五是位 5:值 32 星期六是位 6:值 64

因此,如果报告每周一和周三运行,DaysOfWeek 将是 2 + 8 或 10。

我目前正在自己​​研究这个,所以当我发现更多时我会添加这个。

于 2011-04-11T23:41:13.373 回答