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 2000 Forums
 Transact-SQL (2000)
 update table...

Author  Topic 

tran008
Starting Member

38 Posts

Posted - 2004-07-26 : 14:36:58
Hi all,

I have a table that is constantly adding new records. Every hrs, an email is generate to send out the result of new records. I have a bit column on the table to flag the record as new -0 and old -1. How would I go around updating the record flag as old after an email is generate for the new record, without affecting new record being add during the email process?

thanks

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-26 : 14:38:45
Do your records have a created date or some such? If so, you just need to know the max(CreatedDate) of the records in the generated email. Then update whatever falls before.

Corey
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-07-26 : 14:38:47
You would need to know which rows were e-mailed using an identity column list or maybe the primary key. I guess we'd need to see how you are e-mailing it currently to know how to solve this for you. Please post your code as well as table layout.

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-07-26 : 14:43:33
How many records are we talking about...

A simple UPDATE?

What's the DDL of the table look like?

Does it have a PK?

To be honest, sending an email after every insert doesn't sound like a good idea....

Unless I'm missing the boat....(damn...when the next one?)



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-07-26 : 14:47:43
quote:
Originally posted by X002548



To be honest, sending an email after every insert doesn't sound like a good idea....



Agreed. Although hopefully it isn't after each DML statement and instead maybe a few times per day. But that brings up a good point.

Tran008, you should instead be logging this type of information to a table. Then if anyone needs to see what occurred, they can view the data by querying the table. E-mailing this is most likely causing you performance problems. Are you doing this in a trigger?

Tara
Go to Top of Page

tran008
Starting Member

38 Posts

Posted - 2004-07-26 : 14:49:03
Thanks for getting back so fast...Yes the table have a column that capture the date-time-off-call. As far as the email generated, It only send out a result of capture fields that the operator taked during the call.

thanks
Go to Top of Page
   

- Advertisement -