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?
Use a normal table in
tempdbif 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.tempdbis slightly more efficient in terms of logging requirements.Global temp tables get dropped once
all referencing connections arethe connection that created the table is closed.Edit: Following @cyberkiwi’s edit. BOL does definitely explicitly say
In my test I wasn’t able to get this behaviour though either.
Connection 1
Connection 2
Connection 3