Solved

Create temporary table in SQL Server 2008

Posted on 2011-09-07
2
252 Views
Last Modified: 2012-05-12
Hi,

Can anybody supply me with some code to create a temporary table in SQL Server 2008 from within Delphi. This table will be used to register follwing fields:
Email   Widestring 255
Name  Widestring 255
IsSend Bit Default 0

Usage:
Before sending a mailing all Email-addresses and names  will be stored in this temporary table (per user). When the email (newletter) is sent to a certain Email/Name the IsSend-flag will be changed to TRUE.
If the mailing fails for some reason, this table must remain available for the enduser as long as he/she is working with the application. This way the application can try to continue sending.
After all Emails have been send the temporary table will be removed.
0
Comment
Question by:Delphiwizard
2 Comments
 
LVL 5

Accepted Solution

by:
DavidMorrison earned 500 total points
ID: 36494674
Hi there, is there a reason you want to add and drop the tables afterwards?

why not have a permanent table with a user ID and all the other columns and then simply do a delete from the table when they are done.

The reason I say this is two fold, firstly actual temp tables in sql server are tied to the connection so if for any reason the user loses the conn this table will be lost, secondly is if you wanted a table per user this could make the DB very messy with loads of named tables etc

This being said if you are really set on using temp tables all you need to do is prefix the table name with hash (#) in the create table statement

so you would do:

Create table #UserEmails_<insert user id here>
(
         Email varchar(255),
         Name varchar(255),
         IsSend Bit default 0
)


But as I say I would opt for a perm table rather than the temps


Thanks

Dave
0
 

Author Closing Comment

by:Delphiwizard
ID: 36494710
And thank you for your advise on usage (temp v.s. permanent tabel).
I probalby will create a permanent table with a userID.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

820 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