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

  • Home
  • SEARCH
  • 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 6345927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:55:04+00:00 2026-05-24T20:55:04+00:00

I use temp tables frequently to simplify data loads (easier debugging, cleaner select statements,

  • 0

I use temp tables frequently to simplify data loads (easier debugging, cleaner select statements, etc). If performance demands it, I’ll create a physical table etc.

I noticed recently that I automatically declare my temp tables as global (##temp_load) as opposed to local (#temp_table). I don’t know why but that’s been my habit for years. I never need the tables to be global but I’m curious if there is additional overhead for creating them as global. And should I work on changing my habits.

Are there additional risks for making them global?

  • 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-24T20:55:06+00:00Added an answer on May 24, 2026 at 8:55 pm

    Non-Global temp tables are pretty much guaranteed never to collide.

    Global temp tables are similar to materialized tables in that the name needs to be unique per server.

    As a rule, only use ##GLOBAL_TEMP tables when you must.

    Otherwise, if you are writing a proc that could me run more than once simultaneously, the procs will interact with each other in unpredictable ways, making it extremely difficult to troubleshoot – Instance 1 can change data being used by Instance 2 which causes Instance 3 to generate incorrect results as well.

    My personal opinion on Temp tables is that I only use them when:

    • I have a medium-to-large resultset (more than 1m rows)
    • I will need to index that resultset
    • I will not need to use that resultset more than once per iteration of the process
    • I am confident I will not need to resume the process at any point

    I highlighted that last bullet because this is the main reason I try to minimize temp table use:

    If you have a long-running process, and you use temp tables to store intermediate data sets, and something dies say 90% of the way through, you have to completely restart if that data is not in a materialized table most of the time.

    Some of my processes run for days on billions of rows of data, so I am not interested in restarting from scratch ever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the use of temp tables with a SELECT statement improve the logical
Our client's database admins have requested that we don't use temp tables within our
I need a clarification on whether we can use Temp tables in VIEWS?
I working with legacy (ancient is more appropriate word) application which use temp tables
I would really like to create a view. I know you can't use temp
I am trying to inner join 2 temp tables I know this can be
Which is faster for millions of records: Permanent Table or Temp Tables? I have
To perform transformations in my database, I frequently use a chained set of views.
I'm wanting to do something like SELECT t.subtitle FROM temp t LEFT JOIN ep
I'm using SQL Server 2000, and many of the stored procedures it use temp

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.