Solved

temp table in sql

Posted on 2014-10-15
5
231 Views
Last Modified: 2014-10-15
I want to select from a table and put it in temptable. I created a simple one below. My question is if two users load aspx page
at the same them, let's say, user1 starts first and user2 starts right after, user2 wouldn't  drop #temp_1, right while
user1 running?

DROP TABLE #TEMP_1
SELECT * INTO #TEMP_1
FROM (select itemno, cid, shippdate, etc...) a
0
Comment
Question by:VBdotnet2005
[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
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 167 total points
ID: 40382436
each temp table is unique for session. So in your case answer is yes
0
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 166 total points
ID: 40382442
No you wouldn't have a problem. Tables declared with #temp for example, are only available to that session. If they are named ##temp for example, then they are available globally to all sessions. In your example each user would connect under a different SPID which will prevent any crossover. They would in effect, get their own #temp tables.
0
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 167 total points
ID: 40382446
The above answers are correct.

As an aside, T-SQL will throw an error if it attepts to drop a table that doesn't exist, so add this to your code..
IF OBJECT_ID('tempdb..#TEMP_1) IS NOT NULL
   DROP TABLE #TEMP_1
GO

SELECT * INTO #TEMP_1
FROM (select itemno, cid, shippdate, etc...) a

Open in new window

0
 

Author Comment

by:VBdotnet2005
ID: 40382453
Thanks guys. You are the best.
0
 

Author Comment

by:VBdotnet2005
ID: 40382557
IF OBJECT_ID('tempdb..#TEMP_1') IS NOT NULL
   DROP TABLE #TEMP_1
GO

SELECT * INTO #TEMP_1
FROM (select itemno, cid, shippdate, etc...) a
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

726 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