Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Stored Procedure: union query ignored by Crystal Post Reply Post New Topic
Author Message
gguthrie
Newbie
Newbie


Joined: 06 May 2009
Location: United States
Online Status: Offline
Posts: 13
Quote gguthrie Replybullet Topic: Stored Procedure: union query ignored by Crystal
    Posted: 30 Jan 2011 at 1:29pm
Hello,
 
I am calling a stored procedure using two union queries based on parameters passed from the web page. The results that get returned are the first Select Statement but the Two Union Selects are ignored.
 
I think it might have something to do with using union statements throwing them into #temp tables and then using Union on the temp tables. The reason beng I've used this same union style in another less complicated stored procedure and it works fine.
 
Here's the end result of my stored procedure, which only returns the first Select Statement (ignores the Unions)
 

SELECT Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

FROM #Temp

UNION SELECT Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

FROM #TempB

UNION SELECT Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

FROM #TempC

I have looked around and this seems to be a problem in crystal reports but not in stored procedures. Anyway the way to fix it in crystal is something like this (but this also does not work):
 

Select DB.*

from (

Select 'A' As Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

from #Temp

union

Select 'B' As Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

from #TempB

union

Select 'C' As Letter, ResultCount, Question, Perc, Result, ResultSort, QuestionNumber, sort

from #TempC) DB

Anyone have an idea of why I can't get the UNION data from a stored procedure to show up in Crystal?
 
I'm using Visual Studio 2008 and Microsoft SQL Server 2005. Thanks!
IP IP Logged
gguthrie
Newbie
Newbie


Joined: 06 May 2009
Location: United States
Online Status: Offline
Posts: 13
Quote gguthrie Replybullet Posted: 04 Feb 2011 at 3:55am
I've got this fixed, thanks for looking!
 
It seems my query might have been too long (over 1000 lines), I was able to shorten it and it then took in Crystal.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.