Solved

Create temporary table in SQL Server 2008

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

16 Experts available now in Live!

Get 1:1 Help Now