Solved

using CTE in SSRS reports

Posted on 2013-12-12
5
499 Views
Last Modified: 2014-01-31
I am using a CTE in a SSRS report. the CET works fine when I run it out side of the report. When I run it in the report the data does not display. I see not error message or anything.
0
Comment
Question by:TClevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39715263
I'll bite ... copy-paste the CTE into this question.
0
 

Author Comment

by:TClevel
ID: 39715431
With all_folders AS(
SELECT
CASE WHEN C.Name = '' THEN 'Home' ELSE C.Name END AS ItemName,
C.Description as Report_Description,
LEN(C.Path) - LEN(REPLACE(C.Path, '/', '')) AS ItemLevel,
CASE
WHEN C.type = 1 THEN '1-Folder'
WHEN C.type = 2 THEN '2-Report'
WHEN C.type = 3 THEN '3-File'
WHEN C.type = 4 THEN '4-Linked Report'
WHEN C.type = 5 THEN '5-Datasource'
WHEN C.type = 6 THEN '6-Model'
WHEN C.type = 7 Then '7-ReportPart'
WHEN C.type = 8 Then '8-Shared Dataset'
ELSE '9-Unknown' END AS ItemType,
CASE WHEN C.Path = '' THEN 'Home' ELSE C.Path END AS Path,
ISNULL(CASE WHEN CP.Name = '' THEN 'Home' ELSE CP.Name END, 'Home') AS ParentName,
ISNULL(LEN(CP.Path) - LEN(REPLACE(CP.Path, '/', '')), 0) AS ParentLevel,
ISNULL(CASE WHEN CP.Path = '' THEN ' Home' ELSE CP.Path END, ' Home') AS ParentPath, c.ItemID
FROM
dbo.Catalog AS CP
RIGHT OUTER JOIN
dbo.Catalog AS C ON CP.ItemID = C.ParentID)
select ItemName AS "Report Name", ItemType, ParentPath, ItemID,
  case WHEN ParentLevel = 1
       THEN STUFF(ParentPath, 1, 1, '') ELSE
          SUBSTRING(STUFF(ParentPath, 1, 1, ''), 1, CHARINDEX('/', STUFF(ParentPath, 1, 1, '')) - 1)END AS Applications
from all_folders r INNER JOIN ExecutionLog e ON r.ItemID = e.ReportID
where ItemType = '2-Report' AND (CONVERT(varchar, e.TimeStart, 101) >= CONVERT(varchar,'11/27/2013 12:00:00 AM', 101))
AND (CONVERT(varchar, e.TimeStart, 101) <= CONVERT(varchar, '12/12/2013 12:00:00 AM' , 101))
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 39716872
I'll call in ValentinoV to this question, as he knows more about SSRS then I do.

btw Post your entire data source T-SQL into this question, and specificy whether there are any IF blocks or dynamic SQL in it.  SSRS, like SSIS, requires a 'contract' between a source and a target that does not depend on any conditions.  So, if there is any code that may alter the source for whatever reasons, that will need to be changed to a static set.
0
 
LVL 37

Assisted Solution

by:ValentinoV
ValentinoV earned 250 total points
ID: 39717423
Are you sure the report's data source uses the same DB as when you're testing it in SSMS?
0
 

Author Comment

by:TClevel
ID: 39825321
I've requested that this question be closed as follows:

Accepted answer: 167 points for ValentinoV's comment #a39717423
Assisted answer: 167 points for jimhorn's comment #a39715263
Assisted answer: 0 points for TClevel's comment #a39715431
Assisted answer: 166 points for jimhorn's comment #a39716872

for the following reason:

Thank you all for your help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

751 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