Solved

Create temporary table in SQL Server 2008

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Removing SQL Replication from Microsoft SQL Server 2008 R2 2 34
Query to return total 6 19
SQL Help 27 45
Separate 2 comma delimited columns into separate rows 2 32
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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