?
Solved

Create temporary table in SQL Server 2008

Posted on 2011-09-07
2
Medium Priority
?
258 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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