Search This Blog

Monday, August 23, 2010

How to Copy SQL query from a QC Generated Report or Graph

Subject: Copy SQL query from a QC Generated Report or Graph?

Can you get access to the underlying SQL query on a QC generated Report or Graph? We have several graphs that are only used for the data grid. We want to be able to run a Excel Report to generate this graph. Is the SQL stored in the database somewhere where it can be accessed?


The Profiler tool that comes with SQL Server is useful for determining what call was made on the database by an event on a client tool. For example, if you require a specific SQL statement to get data from Quality Center, you can set up the Profiler and run a report from the Quality Center client. The Profiler will provide you with the SQL statement which was sent to the database for that report. You can then take this statement and customise it as required. Loading the Profiler

1. Remote access into the database server that you require (e.g. PARV01110093)
2. Select Start > All Programs > Microsoft SQL Server > Profiler. The Profiler will load.
3. Select File > New > Trace¦ Provide login details for the correct database instance.

Trace Configuration

General Tab

¢ Give the trace a name.
¢ Template Name SQLProfilerStandard or SQLProfilerTSQL

Events Tab
Add the following event classes:
Stored Procedures
RPC: Starting
SP: StmtCompleted
SP: StmtStarting
SQL: StmtCompleted
SQL: StmtStarting

Data Columns Tab
¢ Select the following data items:

Filters Tab
Filter the trace to report only on a specific database

Running the Trace

As an SQL trace can contain an enormous amount of data, the more specific you can configure it the better. It is also important to start the trace immediately before the client event is executed. Make a note of when the client event is triggered to help you locate it in the trace data.

1. Load the Profiler
2. Configure the trace
3. Load the client application
4. Run the event that you wish to trace
5. Click the Run button on the Profiler
6. The trace will start running. When the tool client process has completed, click the red Stop button on the Profiler toolbar.

Please consult your DBA before running the profiler.