Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 error in temp table in sp

Author  Topic 

sparrow37
Posting Yak Master

148 Posts

Posted - 2009-11-19 : 15:10:47
Hi all,

I have following stored procredure which gives error on execution

alter proc testasif
as
begin
insert into #temp
SELECT [grBrandID], [grBrandName] FROM [USgrBrand] ORDER BY [grBrandName]

select [grBrandID], [grBrandName] FROM #temp
end

error is

Msg 208, Level 16, State 0, Procedure testasif, Line 4
Invalid object name '#temp'.

Please help me on this.

Regards,
Asif Hameed

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-19 : 15:22:06
you have to create the table b4 you can insert data into it. or you can do it on the fly:

SELECT [grBrandID], [grBrandName] into #temp FROM [USgrBrand]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-22 : 00:56:57
also see

http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html
Go to Top of Page
   

- Advertisement -