ADO.NET code to update a temporary table

Posted on 2010-08-26
Last Modified: 2013-12-17

I have some simple code below and I would like to get some ADO.NET code to update a temporary table. Hopefully using Datasets / data tables.


SqlConnection myConn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=CarDB;Integrated Security=True;database=CarDB");

            string str = "create table #temp1 (col1 int, col2 int);";


            // Code to do a dataset to insert some records.


            SqlCommand myCommand = new SqlCommand(str, myConn);



            myCommand.CommandText = "drop table #temp1;";


Open in new window

Question by:whorsfall
  • 3
  • 2

Expert Comment

ID: 33539498
Can you say something about why you are using temporary tables and what you are trying to achieve trough your code? Such information will greatly help in giving you a to-the-point answer :)

You do not need to CREATE local temporary tables. In stead you just SELECT...INTO them. See the following article for basic tips on usage of SQL Servers local temp tables:

Many of the operations done by local temporary tables, that only exists in memory for a given session, can be done more effectively by using derived tables directly in the FROM part of your SELECT statement. A strategy many argue can give increased performance. An example of this is given in this aritcle 

Hope this helps you on your quest..?

Author Comment

ID: 33540839

Thanks for your response. Ok I am building a data acquision application which needs to sample data at a high rate and record for later analysis. We estimate we need to store 400 results at 100 times per second.

So I am trying to find the fastest method to achieve this throughput. This why I was thinking about temporary tables.

I would even be happy with something that can run put it all in memory and only take a shoryt amount of time to save to disk.


Accepted Solution

redpipe earned 500 total points
ID: 33565716
Sorry for the delay, but I've been offline for a couple of days. When it comes to a reply to you question, I first have to admit that I have not worked directly on a solution with such high demands for data caching and object persistence.

If the acquisition part is entirely disconnected from the analysis part, you could do ordinary INSERT statements to a permanent table where one of the columns contains e.g. a binary representation of your 400 resultset. Databases as Berkeley and MySql are both perceived as swift and high capacity 'tools' for object persistence.

You could use queuing, but that is just an externalization of native database caching.

Another solution could be to use specialized databases that are targeted on such caching e.g.DB4o that claims to cache up to 200.000 objects per second (

Author Comment

ID: 33575996

Thanks for the great response - have you tried DB4o it sounds impressive?



Expert Comment

ID: 33584132
No I have not tried it myself. But I've heard great things from a friend of a friend

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now