Solved

Invalid object name '#TEMPSTATUS'.

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Degrading on Write 13 67
Move SQL 2005 Express to Server 2012R2 19 125
Passing value to a stored procedure 8 99
Help  needed 3 23
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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