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
 SQL Server Development (2000)
 Advanced Update Statements

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-30 : 08:29:32
Keith writes "I have a table where I need to weed-out (or change) redundant email addresses, modifying the records with the older time-stamp.

Here's the SELECT statement that gets me those records (but not their ids):
"select email,min(date_entered) from (
Select a.email, a.user_id, a.date_entered
from users a
where a.email in
(Select a.email
from users a
group by a.email
Having count(a.email) >1)) a
group by email
order by email"

Any suggestion on how the UPDATE statement can just modify the record with the older timestamp? I'm bumping into internal errors - when I used an INNER JOIN,though I have SP2 (http://support.microsoft.com/support/kb/articles/Q245/6/31.ASP)- or 'where exists' errors. Any suggestions?

Thanks in advance,
Keith"
   

- Advertisement -