在过程中创建哈希表时无效的表

时间:2016-03-01 09:29:53

标签: sybase

为什么我无法在此过程中创建#表?

drop procedure TESTMD
go
CREATE PROCEDURE TESTMD

AS
declare @SQL_TXT varchar(1000)
BEGIN

SELECT @SQL_TXT ='create table #TESTMD2 (id numeric null)'
exec (@SQL_TXT)
SELECT @SQL_TXT='select * into #TESTMD2 from TESTMD1'
exec (@SQL_TXT)
select @SQL_TXT='insert into #TESTMD2 (id) values(1)'

exec (@SQL_TXT)
END

我收到了错误#TESTMD2 not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).

1 个答案:

答案 0 :(得分:1)

嗯,我不知道为什么在exec中它没有用,但这种方式有效

drop procedure TESTMD
go
CREATE PROCEDURE TESTMD

AS
BEGIN

create table #TESTMD2 (id numeric null)

select * into #TESTMD2 from TESTMD1

insert into #TESTMD2 (id) values(1)


END