Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3760524
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:29:05+00:00 2026-05-19T10:29:05+00:00

Me and another developer are discussing which type of table would be more appropriate

  • 0

Me and another developer are discussing which type of table would be more appropriate for our task. It’s basically going to be a cache that we’re going to truncate at the end of the day. Personally, I don’t see any reason to use anything other than a normal table for this, but he wants to use a global temp table.

Are there any advantages to one or the other?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:29:06+00:00Added an answer on May 19, 2026 at 10:29 am

    Use a normal table in tempdb if this is just transient data that you can afford to lose on service restart or a user database if the data is not that transient.

    tempdb is slightly more efficient in terms of logging requirements.

    Global temp tables get dropped once all referencing connections are the connection that created the table is closed.

    Edit: Following @cyberkiwi’s edit. BOL does definitely explicitly say

    Global temporary tables are visible to
    any user and any connection after they
    are created, and are deleted when all
    users that are referencing the table
    disconnect from the instance of SQL
    Server.

    In my test I wasn’t able to get this behaviour though either.

    Connection 1

    CREATE TABLE ##T (i int)
    INSERT INTO ##T values (1)
    SET CONTEXT_INFO 0x01
    

    Connection 2

    INSERT INTO ##T VALUES(4)
    WAITFOR DELAY '00:01'
    INSERT INTO ##T VALUES(5)
    

    Connection 3

    SELECT OBJECT_ID('tempdb..##T') 
    declare @killspid varchar(10) = (select 'kill ' +  cast(spid as varchar(5)) from sysprocesses where context_info=0x01)
    exec (@killspid)
    SELECT OBJECT_ID('tempdb..##T') /*NULL - But 2 is still 
                                     running let alone disconnected!*/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following bit of code (that another developer wrote) that I need
I've got a repository that has a lot of working code. Another developer on
I recently had a discussion with another developer who claimed to me that JOINs
I am waiting for another developer to finish a piece of code that will
I'm currently rewriting an older AddIn for Excel 2007 that another developer write about
I have a Web Application that I received from another developer, when I first
Background I've picked up some incomplete work from another developer that involves displaying the
I recently had a discussion on another forum with another developer and the topic
I want another developer to run a Perl script I have written. The script
I had another developer ask why I use List all over the place ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.