Solved

Retreiving SQL from Ad-hoc SSRS Report

Posted on 2009-05-14
4
431 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
ID: 24386094
If this is a one-time thing try SQL Profiler to capture the SQL query.
0
 

Author Comment

by:ralphp135
ID: 24387184
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
ID: 24401264
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by Valentino Vranken. Introduction: The first step of creating a SQL Server Reporting Services (SSRS) report involves setting up a connection to the data source and programming a dataset to retrieve data from that data source.  The data…
Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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