I am new to SQL Server, and I am sorry if there is an obvious solution to my question but I can\'t seem to find it.
I am looking to generate a report (or list) of al
The following (which was modified from what beargle posted earlier) does what I was looking for. This will list all the data sources by their actual name, and all their dependent items:
SELECT
C2.Name AS Data_Source_Name,
C.Name AS Dependent_Item_Name,
C.Path AS Dependent_Item_Path
FROM
ReportServer.dbo.DataSource AS DS
INNER JOIN
ReportServer.dbo.Catalog AS C
ON
DS.ItemID = C.ItemID
AND
DS.Link IN (SELECT ItemID FROM ReportServer.dbo.Catalog
WHERE Type = 5) --Type 5 identifies data sources
FULL OUTER JOIN
ReportServer.dbo.Catalog C2
ON
DS.Link = C2.ItemID
WHERE
C2.Type = 5
ORDER BY
C2.Name ASC,
C.Name ASC;
You might also consider using Powershell:
#************************************************************************************************************************************
# FileName: Delete-DataSources.ps1
# Date: 2015/04/23
# Author: Hugh Scott
#
# Description:
# This script finds data sources with no dependencies in SSRS and removes them.
#
# Parameters:
# $serverBase - base URL for the server to check (ie, myserver.mydomain.com)
# [$WhatIf] - Option wwitch parameter to prevent actual deleting of objects (will list out reports that need to be deleted)
#***********************************************************************************************************************************
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=0)]
[string]$serverBase,
[Parameter(Mandatory=$false,Position=1)]
[switch]$WhatIf
)
$url = "http://$serverBase/reportserver/ReportService2010.asmx?WSDL"
$ssrs = New-WebServiceProxy -uri $url -UseDefaultCredential -Namespace "ReportingWebService"
$outFile = ".\DeleteItems_$serverBase.txt"
# Connection to Web Service, grab all data sources
$items = $ssrs.ListChildren("/", $true) | where-object {$_.typename -eq "DataSource"}
foreach($item in $items) {
$dependencies = $ssrs.ListDependentItems($item.Path)
$dependentReports = $dependencies.Count
if($dependencies.Count -eq 0){
[string]$itemName = $item.Path
if($WhatIf){
Write-Host "Item $itemName would be deleted."
Add-Content $outFile "Item $itemName would be deleted."
} else {
try {
$ssrs.DeleteItem($item.Path)
Write-Host "Item $itemName deleted."
Add-Content $outFile "Deleted item $itemName ."
} catch [System.Exception] {
$Msg = $_.Exception.Message
Write-Host $itemName $Msg
Add-Content $itemName $msg
}
}
}
}
This query should be run against the ReportServer
database
SELECT
DS.Name AS DatasourceName,
C.Name AS DependentItemName,
C.Path AS DependentItemPath
FROM
ReportServer.dbo.Catalog AS C
INNER JOIN
ReportServer.dbo.Users AS CU
ON C.CreatedByID = CU.UserID
INNER JOIN
ReportServer.dbo.Users AS MU
ON C.ModifiedByID = MU.UserID
LEFT OUTER JOIN
ReportServer.dbo.SecData AS SD
ON C.PolicyID = SD.PolicyID AND SD.AuthType = 1
INNER JOIN
ReportServer.dbo.DataSource AS DS
ON C.ItemID = DS.ItemID
WHERE
DS.Name IS NOT NULL
ORDER BY
DS.Name;
The dependent items page in Report Manager executes the dbo.FindItemsByDataSource
stored procedure, supplying these parameters: ItemID = <data source item ID>
and AuthType = 1
. The above query is a hacked version of the query used by this stored procedure to remove the data source specific ID. This allows dependent items to be returned for all data sources. I removed the data sources themselves from the results with DS.Name IS NOT NULL