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!