Solved

# vs ##

Posted on 2013-10-24
2
146 Views
Last Modified: 2013-10-24
1)
when a stored proc uses a temp table, and that sp will be hit by 10s of users at the same time, which is more preferred for temptables - # or ##?

2)
which is better for indexing? # or ## tables?
0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 100 total points
ID: 39596701
why not create a permanent table then? your sp wouldn't to handle table creation, indexes, ...
0
 
LVL 5

Accepted Solution

by:
MohitPandit earned 400 total points
ID: 39596775
Hello,

1. For concurrency you need to use Local temp table only i.e. (#) NOT Global temp table (i.e. ##).
Please note, if you will use ## then DB engine will give an error in case concurrent execution same procedure by multiple users
There is already an object named '##...' in the database

2. Indexes performs same on both.

You may also take a look over this link
https://www.simple-talk.com/sql/t-sql-programming/temporary-tables-in-sql-server/

Kindly take a look over it and let me know in case you have any concern.

Best Regards,
Mohit Pandit
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Union 2 queries to a cte (temp table perhaps) 9 49
What is this datetime? 1 28
SQL Select Query help 1 37
Need multiple Group By's 8 24
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question