Solved

Invalid object name '#TEMPSTATUS'.

Posted on 2009-07-07
3
171 Views
Last Modified: 2013-11-05
Can somebody explain to me why I am getting this error:
Invalid object name '#TEMPSTATUS'.
when i execute the query below?

SELECT DISTINCT
	I.INSTNAMENO AS NAMENO,
	I.POLICY AS LINEOFBUSINESS,
	CASE WHEN I.STATUS IN (0,1,13) THEN 'Not Started'
	ELSE CASE WHEN I.STATUS IN (2,3,4,5,6,7,14) THEN 'In Progress'
	ELSE CASE WHEN I.STATUS IN (8,9,10) THEN 'Under Review'
	ELSE CASE WHEN I.STATUS IN (11,12) THEN 'Complete'
	ELSE CASE WHEN I.STATUS IN (11,12) THEN 'Non-renewed Application'
	ELSE '' END END END END END AS PMRSTATUS,
	'EAF APPLICATION' AS TXNTYPE,
	I.YEAR AS YEAR
 
INTO #TEMPEAF
FROM UE_EAF..APPLICATION I
 
WHERE 
	I.YEAR >= DATEPART(YYYY,DATEADD(YYYY,-1,GETDATE()))
	AND I.INSTNAMENO = @NameNo
 
 
-----------------------COMBINE ALL TEMP TABLES---------------------------
SELECT DISTINCT
	T2.NAMENO,
	T2.LINEOFBUSINESS,
	T2.PMRSTATUS,
	T2.TXNTYPE,
	T2.YEAR
FROM #TEMPEAF T2
 
WHERE 
	T2.NAMENO <> 0
	AND T2.NAMENO = @NameNo
	AND T2.LINEOFBUSINESS IS NOT NULL
 
UNION
 
SELECT DISTINCT
	T.NAMENO,
	T.LINEOFBUSINESS,
	T.PMRSTATUS,
	T.TXNTYPE,
	T.YEAR
FROM #TEMPSTATUS T
 
WHERE T.NAMENO = @NameNo
	AND T.LINEOFBUSINESS IS NOT NULL
 
ORDER BY YEAR, TXNTYPE DESC
 
 
DROP TABLE #TEMPSTATUS
 
DROP TABLE #TEMPEAF
END
 
END

Open in new window

0
Comment
Question by:snazaire
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 24792036
you have inserted data only in #TEMPEAF

not in #TEMPSTATUS

where you are creating teh tav\ble and inserting data in #TEMPSTATUS ? like #TEMPEAF
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24792049
You are obtaining the error since you haven't created the temp table #TEMPSTATUS at all.
And you are issuing a SELECT statement in this non-existing table which error-ed out.

Kindly create that table and hope this helps
0
 

Author Comment

by:snazaire
ID: 24792069
Thank you rrjeqan17, but pratima answered already the same way.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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