Question

I am trying to extract the sql from all my SSRS reports so I can see what database tables and columsn are used . Does anyone know how to do this if you have 50 reports ? Is there any exsiting functionality I have overlooked that does this ?

Was it helpful?

Solution

The RDL files are simple XML files. You could create a simple parser that extracts the information you want. If you don't have access to the RDL files right now, you can download them through the SSRS web interface.

Here's an excerpt of the relevant part of an RDL file:

<DataSets>
<DataSet Name="Test">
  <Fields>
    <Field Name="Testfield">
      <DataField>Testfield</DataField>
      <rd:TypeName>System.DateTime</rd:TypeName>
    </Field>
  </Fields>
  <Query>
    <DataSourceName>MyDataSource</DataSourceName>
    <CommandType>StoredProcedure</CommandType>
    <CommandText>spMyGreatStoredProcedure</CommandText>
    <QueryParameters>
      <QueryParameter Name="@param1">
        <Value>=Parameters!Param1.Value</Value>
      </QueryParameter>
      <QueryParameter Name="@param2">
        <Value>=Parameters!Param2.Value</Value>
      </QueryParameter>
    <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
  </Query>
</DataSet>
</DataSets>

There are one or more DataSet blocks, which define one data set of the report. First, all the fields are defined and then the query with its parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top