COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Sheldon on 13 May 2010 09:18:00 AM

Title: Showing SQL For A Query
Post by: Sheldon on 13 May 2010 09:18:00 AM
My report is in Page1 which uses Query1.  Now if I create an independent query (Query2) for my own testing purposes, unrelated to Page1, and want to see the SQL for that query, Tools/Show Generated SQL/MDX only shows me the SQL for Query1 and nothing I do seems to allow me to see the SQL for Query2.  Any ideas?

Thanks, Sheldon
Title: Re: Showing SQL For A Query
Post by: CognosPaul on 13 May 2010 09:25:55 AM
Tool-->Show Generated SQL/MDX will show you the SQL for the objects in the report. Different objects based on the same query can have drastically SQL. You can view the SQL for individual queries by selecting the query through query explorer and clicking on Generated SQL.

Cognos will remove any unused data items when it generates the SQL for each object. For example, if you have a query with Year, Month and Sales the query's generated sql will probably look like:

select year, month, sum(sales) from table group by year, month

If you make a graph showing only years and sales Cognos will automatically remove the month from the SQL making it look like:
select year, sum(sales) from table group by year
Title: Re: Showing SQL For A Query
Post by: Sheldon on 13 May 2010 10:56:10 AM
Thanks Paul but I had tried what you suggested previously and it hadn't worked.  i.e. No SQL was shown for Query2.  Logically, it seemed like it should've worked...

Sheldon
Title: Re: Showing SQL For A Query
Post by: kattaviz on 13 May 2010 11:19:27 AM
Hi,

Just drag the Query2 to a seperate page and then try the Generated SQL property for Query2.
Title: Re: Showing SQL For A Query
Post by: Sheldon on 13 May 2010 12:08:51 PM
Thank you Satish.  I went to Query Explorer, highlighted Query2 but I wasn't sure what to do from there.  Should I also be creating a new page first and somehow associate that page (Page2) with Query2? 

Thanks, Sheldon
Title: Re: Showing SQL For A Query
Post by: rockytopmark on 13 May 2010 02:07:45 PM
Click on Query 2 in the explorer, then go to the properties area, and locate the Show Generated SQL/MDX, and click the ... to have it generate.
Title: Re: Showing SQL For A Query
Post by: Sheldon on 14 May 2010 08:29:25 AM
Thanks. Highlighting Query2 in Query Explorer, then Properties, then clicking on the ellipsis for Generated SQL worked!
Sheldon