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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Create temp table in stored procedure and SQL7

Author  Topic 

ivanss11
Starting Member

2 Posts

Posted - 2001-03-18 : 10:39:14
Hi all,
I try to a simple stored procedure that creates a temporary table and have problem.
I tray this example:

CREATE PROCEDURE TEST9 AS
declare @strTemp1 varchar(300)

set @strTemp1 = "create table #MYTABLE( id int, id1 int ) "
print @strTemp1
exec (@strTemp1)


set @strTemp1 = "select * from #MYTABLE "
print @strTemp1
exec (@strTemp1)



return(0)


The result is :
exec TEST9

create table #MYTABLE( id int, id1 int )
select * from #MYTABLE
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name '#MYTABLE'.


Any Ideas ?
I try without exec (@strTemp1) and all is OK, but I neeed to make my procedure with exec.




   

- Advertisement -