Access to temp tables across stored procedures

  • Hi ,

    can you tell me how to access temp table information(values) in one stored procedure from other stored procedure

    Eg.,

    create table Ta

    (

    a varchar(10)

    )

    insert into Ta values('a')

    Create proc sp1

    as

    select * into #TmpA  from Ta

     

    Creatte proc sp2

    as

    declare @a varchar(10)

    set @a = (select * from #TmpA)

    print @a

    when i excute

    exec sp2

    it shows the following error....

    Invalid object name '##TmpA'.

  • The temp table #TmpA is out of scope for the sproc sp2.

    You can either create the temp table in sp1 as ##TmpA making it global, or call sp2 from within sp1 so that it remains in scope.

     


    Christopher DeMeyer

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply