Solved

Create temporary table in SQL Server 2008

Posted on 2011-09-07
2
254 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
[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
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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

737 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