简体   繁体   中英

Extracting sql from SSRS Reports

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM