Solved

Invalid object name '#TEMPSTATUS'.

Posted on 2009-07-07
3
169 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now