Why invalid table message

Last Post 29 Jun 2010 06:01 PM by gunneyk. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
werice
New Member
New Member

--
29 Jun 2010 05:22 PM
I have a stored procedure that has the foloowing code.


SELECT column1,
      column2,
                  .
                  ,
                  ,
      column10
INTO #testtemptable
 group by
      column1,
      column2,
                  .
                  .
                  .
      column10


select invoiceid, amount,siteid,agency
         into #myupdate table from
         invoice


update #testtemptable 
      set OctAmount = (select amount from
            #myupdate where
               #testtemptable.siteid = #myupdate.siteid
            and #testtemptable.agency = #myupdate.agency


How come when I try to create the SP I get the
Error:
   #testtemptable invalid table name.  is it becasue the table has not been created?
gunneyk
New Member
New Member

--
29 Jun 2010 06:01 PM
Yes the error is due to the fact the tables don't exist at the time the sp is created. You can simply create them in that same query editor window before you run the CREATE PROC statement and it will go thru. But I don't see a need for temp tables at all here from the example you shown. You should be able to come up with a single statement with possibly some subselects to accomplish the goal.
You are not authorized to post a reply.

Acceptable Use Policy