Solved

Invalid object name '#TEMPSTATUS'.

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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 we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

11 Experts available now in Live!

Get 1:1 Help Now