Solved

Retreiving SQL from Ad-hoc SSRS Report

Posted on 2009-05-14
4
423 Views
Last Modified: 2012-08-14
I have a user that created an ad-hoc report in SQL Server 2005.  When I log into the SQL Server DB and export the report to an RDL file for editing, the DataSource is in XML (NOT SQL)and therefore when I load the RDL file in a Visual Studio Solution, I cannot click the Data tab and see the SQL for the report.  Nor can I hit the preview button.

If I try and export the DataModel or Dataset from the DB and add it to the solution it does not add to the datasource section.  It adds it under the report in the solution explorer.

I need to somehow get the exact SQL that this report has internally from the RDL which runs against a datamodel in the DB.

Any ideas?
0
Comment
Question by:ralphp135
4 Comments
 
LVL 9

Expert Comment

by:cdaly33
Comment Utility
If this is a one-time thing try SQL Profiler to capture the SQL query.
0
 

Author Comment

by:ralphp135
Comment Utility
What i am looking for is 1) to get the SQL from the RDL and 2) to be able to take these adhoc reports and migrate them into a full development environment in files such as RDL that I can put in Visual Source Safe.
0
 
LVL 1

Accepted Solution

by:
billinb earned 500 total points
Comment Utility
9:10 PM 5/15/2009

The SQL profiler solution actually is the best way to go here, I'll explain.
If it were possible to glean any useful information from the model, You would need to create a Report Model project rather than a Report Server project, then observe the model in VS.

But you wouldn't see any additional information regards the SQL.  A model establishes table/entity relationships, measures, attributes, etc for analysis type reporting and drag and drop functionality.

Note that the connections for the existing models are probably in the root folder, and the models are probably in a 'Models' folder on RM.  Click the show details to view all objects.

So back to profiler, I'll make it easy and it'll be painless.

Assuming you can log to the SQL server that SSRS management resides on:
Tools/Profiler;  File/New Trace;
Login;
Use Standard Default on the General tab, then click on Events Selection.
Click Column Filters;
Select Login Name, then type like 'ReportingServices'.
Click Run;
Pause and Clear the trace;
Run the report in Manager;
Alt Tab back to profiler quickly, and Stop the Trace as soon as the report finishes;
Ctrl-F Find, to find an Exec or some other object name in order to find the SQL that was generated when the report was run.  Replace Scalars with formulas in your SQL (the model will generate literals).

Paste that SQL into a new Report Server's RDL report's dataset SQL and create a new report.  Move the old report and deploy the new rdl report in its place, or deploy the new report in a different folder, or create a linked report to the new one.

This should save you time and make it easier to gather any SQL you might need to consolidate.  You can always migrate toward analysis (model) reports later.

Hope this helped.

Bill
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now