我正在搜索并尝试几个小时来获取一个查询,该查询从SSRS服务中获取所有当前订阅的参数及其值,以便可以在新服务器上重新创建它们(修剪后)。
例如,一个简单的报告可能是HoursByDepartment,需要三个参数:
@From =Today - 7 days (Default)
@To = Today (Default)
@Dept = 2 (part of subscription)
我想得到的是这些内容(或者让我创建报告的内容)
Report ParamName ParamValue Default
HoursByDepartment From Today-7days True
HoursByDepartment To Today True
HoursByDepartment Dept 2 False
OR
Report Param1Name Param1Value Param1Def Param2Name Param2Value Param2Def
HoursByDepartment From Today-7days True To Today True
我对XSl非常好,所以如果我能得到类似的东西,我可以使用它:
<subid>
<report>
<ParameterValues>
<ParameterValue>
<Name>MinAvailable</Name>
<Value>10000</Value>
</ParameterValue>
<ParameterValue>
<Name>OwnerIDs</Name>
<Value>0</Value>
</ParameterValue>
<ParameterValue>
<Name>ShowCosts</Name>
<Value>False</Value>
</ParameterValue>
<ParameterValue>
<Name>MinValue</Name>
<Value>0</Value>
</ParameterValue>
</ParameterValues>
</report>
</subid>
答案 0 :(得分:5)
这个脚本应该让你有个好的开始。对于每个报告订阅,此查询将为每个参数返回一行,对于不使用参数的订阅,只返回一行。如果您希望转换它,则可能必须重新编写脚本才能以xml格式获取它。
这是从Listing Subscribed SSRS Reports including Parameters & their Values得出的(不知道原来我改变了多少,如果有的话。)
WITH
[Sub_Parameters] AS
(
SELECT
[SubscriptionID],
[Parameters] = CONVERT(XML,a.[Parameters])
FROM [Subscriptions] a
),
[MySubscriptions] AS
(
SELECT DISTINCT
[SubscriptionID],
[ParameterName] = QUOTENAME(p.value('(Name)[1]', 'nvarchar(max)')),
[ParameterValue] = p.value('(Value)[1]', 'nvarchar(max)')
FROM
[Sub_Parameters] a
CROSS APPLY [Parameters].nodes('/ParameterValues/ParameterValue') t(p)
),
[SubscriptionsAnalysis] AS
(
SELECT
a.[SubscriptionID],
a.[ParameterName],
[ParameterValue] =
(SELECT
STUFF((
SELECT [ParameterValue] + ', ' as [text()]
FROM [MySubscriptions]
WHERE
[SubscriptionID] = a.[SubscriptionID]
AND [ParameterName] = a.[ParameterName]
FOR XML PATH('')
),1, 0, '')
+'')
FROM [MySubscriptions] a
GROUP BY a.[SubscriptionID],a.[ParameterName]
)
SELECT
a.[SubscriptionID],
c.[UserName] AS Owner,
b.Name,
b.Path,
a.[Locale],
a.[InactiveFlags],
d.[UserName] AS Modified_by,
a.[ModifiedDate],
a.[Description],
a.[LastStatus],
a.[EventType],
a.[LastRunTime],
a.[DeliveryExtension],
a.[Version],
e.[ParameterName],
LEFT(e.[ParameterValue],LEN(e.[ParameterValue])-1) as [ParameterValue],
SUBSTRING(b.PATH,2,LEN(b.PATH)-(CHARINDEX('/',REVERSE(b.PATH))+1)) AS ProjectName
FROM
[Subscriptions] a
INNER JOIN [Catalog] AS b
ON a.[Report_OID] = b.[ItemID]
LEFT OUTER JOIN [Users] AS c
ON a.[OwnerID] = c.[UserID]
LEFT OUTER JOIN [Users] AS d
ON a.MODIFIEDBYID = d.Userid
LEFT OUTER JOIN [SubscriptionsAnalysis] AS e
ON a.SubscriptionID = e.SubscriptionID;
但是,如果这是从2005年到2008年的升级,您可能需要考虑using this tool。如果要从此服务器中删除SSRS并使用相同版本移动到其他服务器,则最好将整个reportserver和reportservertempdb数据库移动为explained by Microsoft here。
答案 1 :(得分:1)
下面是@dev_etter查询的一个版本,已更新为也返回扩展设置。
WITH
[Sub_Parameters] AS
(SELECT
[SubscriptionID],
[Parameters] = CONVERT(XML,a.[Parameters]),
[ExtensionSettings] = CONVERT(XML,a.[ExtensionSettings])
FROM [Subscriptions] a
)
, [MySubscriptions] AS (
SELECT --DISTINCT
[SubscriptionID],
[ParameterName] = QUOTENAME(p.value('(Name)[1]', 'nvarchar(max)')),
[ParameterValue] = p.value('(Value)[1]', 'nvarchar(max)')
FROM [Sub_Parameters] a
CROSS APPLY [Parameters].nodes('/ParameterValues/ParameterValue') t(p)
UNION
SELECT --DISTINCT
[SubscriptionID],
[ExtensionSettingName] = QUOTENAME(e.value('(Name)[1]', 'nvarchar(max)')),
[ExtensionSettingValue] = e.value('(Value)[1]', 'nvarchar(max)')
FROM [Sub_Parameters] a
CROSS APPLY [ExtensionSettings].nodes('/ParameterValues/ParameterValue') t(e)
)
, [SubscriptionsAnalysis] AS (
SELECT
a.[SubscriptionID],
a.[ParameterName],
[ParameterValue] =
(SELECT STUFF((SELECT [ParameterValue] + ', ' as [text()]
FROM [MySubscriptions]
WHERE [SubscriptionID] = a.[SubscriptionID]
AND [ParameterName] = a.[ParameterName] FOR XML PATH('')),1, 0, '')+'')
FROM [MySubscriptions] a
GROUP BY a.[SubscriptionID],a.[ParameterName]
)
SELECT
a.[SubscriptionID],
c.[UserName] AS [Owner],
b.[Name],
b.[Path],
a.[Locale],
a.[InactiveFlags],
d.[UserName] AS [Modified_by],
a.[ModifiedDate],
a.[Description],
a.[LastStatus],
a.[EventType],
a.[LastRunTime],
a.[DeliveryExtension],
a.[Version],
e.[ParameterName],
LEFT(e.[ParameterValue],LEN(e.[ParameterValue])-1) as [ParameterValue],
SUBSTRING(b.[PATH],2,LEN(b.[PATH])-(CHARINDEX('/',REVERSE(b.[PATH]))+1)) AS [ProjectName]
FROM [Subscriptions] a
INNER JOIN [Catalog] AS b ON a.[Report_OID] = b.[ItemID]
LEFT OUTER JOIN [Users] AS c ON a.[OwnerID] = c.[UserID]
LEFT OUTER JOIN [Users] AS d ON a.[ModifiedByID] = d.[Userid]
LEFT OUTER JOIN [SubscriptionsAnalysis] AS e ON a.[SubscriptionID] = e.[SubscriptionID]
;
答案 2 :(得分:1)
这对于评估给定报表的预订中特定参数的使用很有帮助,尤其是当参数变为强制性时,查看需要更新哪些预订。
我进行@Chumz查询,是因为它比@dev_etter更清晰,并对其进行了修改,以显示数据驱动的订阅的参数,而参数XML中没有Sub IMPORTAR2()
Dim myDir As String, fn As String, txt As String, a(), n As Long, i As Long, ff As Integer
myDir = "C:\Users\epontes\Desktop\TDFA 13228 CDP\" '<- Mude de acordo com a necessidade
fn = Dir(myDir & "*.*")
Do While fn <> ""
ff = FreeFile
Open myDir & "\" & fn For Input As #ff
Do While Not EOF(ff)
Line Input #ff, txt
If InStr(Left(text, 4), "1234") > 0 Then
n = n + 1: ReDim Preserve a(1 To n)
a(n) = Split(txt, vbTab)
Close #ff
fn = Dir()
Loop
With ThisWorkbook.Sheets(2).Range("a1")
For i = 1 To n
.Offset(i - 1).Resize(, UBound(a(i)) + 1).Value = a(i)
Next
End With
End Sub
却只有<Value>
:
<Field>