[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Insert tables from a dataset into a temp table

Posted on 2005-04-20
7
Medium Priority
?
466 Views
Last Modified: 2008-02-20
Hello,
I would like to insert brand new records, but I don't want to save it to a database, rather insert them into a temp table, run a stored procedure against it, and then clear the temp table out of memory.  Is that even possible?  Thanks.  

P.S.  I was thinking of using a global temp table, but I'm hesitant...
0
Comment
Question by:ispcorp
  • 3
  • 2
  • 2
7 Comments
 
LVL 13

Expert Comment

by:davidlars99
ID: 13824582
you have to first create temporary table

CRATE TABLE #myTable (...)

and insert data

INSERT INTO #myTable (...) VALUES (...)

and then empty/truncate it

TRUNCATE TABLE #myTable


when you create tables with "#" sign, they autonaticaly are placed in temp database
0
 
LVL 23

Assisted Solution

by:b1xml2
b1xml2 earned 2000 total points
ID: 13824796
CREATE PROC spGetData
AS
DECLARE @table TABLE (ID int Identity(1,1) not null, User varchar(10) null,Date datetime null)
insert @table
(User,Date)
select
      username as User,
      dob as Date
from
      mytable
      


'process table
'when the procedure ends, the table is cleared
      
0
 
LVL 2

Author Comment

by:ispcorp
ID: 13825104
I should have mentioned that I'm creating the temp table within asp.net

Will the table still exist even if its a separate transaction?
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 23

Accepted Solution

by:
b1xml2 earned 2000 total points
ID: 13825205
ahh =) i c the light, why dont you have an actual table with GUID being the identifier of that request pipeline and you can manipulate data and then you can clear it up.... That way transactional and scoping issues are handled.
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13825217
table will exist until you reboot the computer
0
 
LVL 2

Author Comment

by:ispcorp
ID: 13825342
Actually davidlars99...The table was cleared from memory as soon as the transaction ended.  There were two ways I could do it...Keep the transaction alive by not comitting it, or creat a "GLOBAL" temp table with "##" in front of its declaration, which would be kept on the temp database until you explicitly drop it.

I chose to create a global temp table with sessionid as part of its name, do my  processing with the stored procedure, and then drop it when I'm done with it.  

b1xml2 was right about, but I found a work around using GLOBAL temp tables.

Davidlars...Do you rebuke anything I just said?
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 13825449
no, I don't rebuke.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

834 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