Solved

Invalid object name '#TEMPSTATUS'.

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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