Solved

# vs ##

Posted on 2013-10-24
2
145 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
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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