Avatar of Mohlerp1942
Mohlerp1942

asked on 

Microsoft Reporting Services - SQL Query

I have three datasets two that populate a temporary table called  ##GlobalTable1 the first dataset creates the global table and inserts records. Query shown below is Dataset "GlobalLocalTable"
SELECT ASSMNT_TOPIC_1.ASSMNT_TOPIC_NAME AS Column1, COND_TOPIC_1.COND_TOPIC_NAME AS Column2Name, dbo.COND_TOPIC.COND_TOPIC_NAME AS Column3,
            COUNT(COND_TOPIC_1.COND_TOPIC_NAME) AS Column2Count
INTO    [##GlobalTable1]
FROM   dbo.COND INNER JOIN
            dbo.COND_TOPIC ON dbo.COND.COND_TOPIC_ID = dbo.COND_TOPIC.COND_TOPIC_ID INNER JOIN
            dbo.COND_TOPIC COND_TOPIC_1 ON dbo.COND_TOPIC.PARENT_COND_TOPIC_ID = COND_TOPIC_1.COND_TOPIC_ID INNER JOIN
            dbo.ASSMNT_TOPIC ON dbo.COND_TOPIC.PARENT_COND_TOPIC_ID = dbo.ASSMNT_TOPIC.ASSMNT_TOPIC_ID INNER JOIN
            dbo.ASSMNT_TOPIC ASSMNT_TOPIC_1 ON dbo.ASSMNT_TOPIC.PARENT_ASSMNT_TOPIC_ID = ASSMNT_TOPIC_1.ASSMNT_TOPIC_ID
WHERE (dbo.COND.INSERT_DATE >= @BeginPeriod) AND (dbo.COND.INSERT_DATE <= @EndPeriod)
GROUP BY ASSMNT_TOPIC_1.ASSMNT_TOPIC_NAME, dbo.COND_TOPIC.COND_TOPIC_NAME, COND_TOPIC_1.COND_TOPIC_NAME
ORDER BY ASSMNT_TOPIC_1.ASSMNT_TOPIC_NAME, COND_TOPIC_1.COND_TOPIC_NAME, dbo.COND_TOPIC.COND_TOPIC_NAME

The second query appends records to same table. See below! This Dataset is "InsertIntoGlobalTable"
INSERT INTO [##GlobalTable1]
SELECT COND_TOPIC_1.COND_TOPIC_NAME AS Column1, dbo.COND_TOPIC.COND_TOPIC_NAME AS Column2Name, 'N/A' AS Column3, COUNT(dbo.COND_TOPIC.COND_TOPIC_NAME)
            AS ColumnCount
FROM   dbo.COND INNER JOIN
            dbo.COND_TOPIC ON dbo.COND.COND_TOPIC_ID = dbo.COND_TOPIC.COND_TOPIC_ID INNER JOIN
            dbo.COND_TOPIC COND_TOPIC_1 ON dbo.COND_TOPIC.PARENT_COND_TOPIC_ID = COND_TOPIC_1.COND_TOPIC_ID
WHERE (dbo.COND.INSERT_DATE >= @BeginPeriod) AND (dbo.COND.INSERT_DATE <= @EndPeriod)
GROUP BY COND_TOPIC_1.COND_TOPIC_NAME, dbo.COND_TOPIC.COND_TOPIC_NAME, COND_TOPIC_1.PARENT_COND_TOPIC_ID
HAVING (COND_TOPIC_1.PARENT_COND_TOPIC_ID IS NULL)

The third dataset queries the temporary table. See query below! Dataset name is "GetLocalGlobal"
SELECT Column1, Column2Name, Column3, Column2Count
FROM   [##GlobalTable1]
I want to use the third Dataset to populate my report.

When I test these queries from the Data tab they work, but when I try to run the report I get the error message
 "An error has occurred during processing. Query execution failed for dataset "GetLocalGlobal" invalid object name '##GlobalTable1'
I don't understand the error message.
DB Reporting Tools

Avatar of undefined
Last Comment
simon_kirk
ASKER CERTIFIED SOLUTION
Avatar of simon_kirk
simon_kirk
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
DB Reporting Tools
DB Reporting Tools

A database report is the formatted result of database queries and contains useful data for decision-making and analysis. Most good business applications contain a built-in reporting tool; this is simply a front-end interface that calls or runs back-end database queries that are formatted for easy application usage.

8K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo