Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 pls help

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2009-10-01 : 02:38:10
My question is, each time I send an email, the email has a tracker image that has querystring values of username and emailid. This two values will be inserted into my "email_tracker" table. (Both username and emailid is unique - 1 username may have several emailid's)

However now, I want to add a campaignid to my table each time an email is sent out.

So for instance I sent out 2 emails now, I want this 2 emails to have a campaignid of value 1. And when I click my send button again, the campaignid will have value 2. Im still cracking my skull thinking of how to implement this and what columns to add in my table.So the data in my table may be something like

username emailid campaignid

jessie 1 1

jessie 1 2

And as per my previous thread, Ive decided NOT to have a counter column and I will just take the SUM of all the emails sent based on the campaignid, because I am going to append dates to each email that was read so I can display in my gridview a datetime column.

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-01 : 02:40:56
you can make campaignid an int column and give campaignid value as SELECT COALESCE(MAX(campaignid),0)+1 FROM yourtable for each insert
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2009-10-01 : 02:58:24
hi visakh16,
but,
campaignid has to be incremented once for username/emailid combination.

that means

action campaignid+1 MAX(campaignid),0)+1
campaignid(1) campaignid(2)
sent User1/email1 1 1
sent User2/email1 1 2
sent User1/email2 1 3
sent User1/email1 2 4
sent User1/email2 2 5
sent User1/email2 3 6

Select * from email_tracker will be

Username EmailId campaignid(1) campaignid(2)

User1 email1 2 4
User1 email2 3 6
User2 email1 1 2

I'm don't want values of campaignid(2).
only i need campaignid(1)


One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-01 : 03:03:05
do you do one by one or batch insert?
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2009-10-01 : 03:04:45
one by one only,for each button click from asp.net application i need to perform this

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-01 : 03:08:14
so for each of records inserted you want same value of campaignid? what determines how long you want this value before it changes?
Go to Top of Page
   

- Advertisement -