Is there any way to Query temp tables in tempdb ?

Last post 08-22-2008, 2:55 AM by Phil Factor. 3 replies.
Sort Posts: Previous Next
  •  08-11-2008, 10:44 PM Post number 67888

    Is there any way to Query temp tables in tempdb ?

    Hi all

     

    Is there any way to view the records in the temp tables created by stored procs(SQL created this tables in tempdb)

     

    Thanks

    Dyanesh

  •  08-18-2008, 2:44 AM Post number 69039 in reply to post number 67888

    • MVV is not online. Last active: 12-01-2008, 6:48 AM MVV
    • Top 25 Contributor
    • Joined on 04-29-2008
    • Alcoy, Spain
    • Level 2: Deep Blue

    Re: Is there any way to Query temp tables in tempdb ?

    it depends if their names begin with  "#"  or with "##". It's all in the documentation of sqlserver , under temp tables.


    Hey , sysadm , leave the users alone
    They are nothing more
    than another brick in the firewall
  •  08-21-2008, 9:29 PM Post number 69194 in reply to post number 69039

    Re: Is there any way to Query temp tables in tempdb ?

    It is possible to query temp tables.  You can create temp tables as simple as select * into #foo2 from foo where foobar = 'xxx'.  Now your temp table #foo2 contains only foobar's = 'xxx'.  ##Tablename are global.  I will leave it to you to figure out how long a temp table persists.

     

    Jason

  •  08-22-2008, 2:55 AM Post number 69197 in reply to post number 69194

    Re: Is there any way to Query temp tables in tempdb ?

    I give a little example here of how to do it.

    http://www.simple-talk.com/community/blogs/philfactor/archive/2007/07/13/33494.aspx
View as RSS news feed in XML