?
Solved

Invalid object name '#TEMPSTATUS'.

Posted on 2009-07-07
3
Medium Priority
?
174 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
[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
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

771 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