July 18, 2003 at 4:38 am
Thanks Frank, appreciated
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
July 18, 2003 at 4:52 am
I can particularly relate to the one about c++.........
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
July 18, 2003 at 5:11 am
could I not implement some kind of loop construct..heres what I have..its quite self explanatory....
delete t1
from unique_cust t1 INNER JOIN unique_cust t2
on t1.dup_code = t2.dup_code
and t1.rec_lda < t2.rec_lda
and t1.dup_code <> 0
and t2.dup_code <> 0
Declare @cust_iddelete varchar(255)
Declare @cust_idkeep varchar(255)
Declare @id int
/*Set @id = ?*/
select @cust_idkeep = t1.cust_id from unique_cust t1
Where t1.cust_id=@id
/*Set @id = ?*/
select @cust_iddelete = t2.cust_id from unique_cust t2
Where t2.cust_id=@id
update unique_transactions
set cust_id = @cust_idkeep
where cust_id = @cust_iddelete
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
Edited by - achowe on 07/18/2003 05:12:14 AM
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
July 18, 2003 at 12:47 pm
achowe, Why won't Npeeters query work for you? That's a nice little piece of code, deletes all records except the one with the maximum date value.
DELETE t1
FROM MyTable t1
JOIN MyTable t2 ON t1.Unique_ID = t2.Unique_ID AND t1.DateField < t2.DateField
And, if you have an identity column and you insert earliest dates first then you should use that instead. SQL handles integers a lot better than dates.
--something like...
DELETE t1
FROM MyTable t1
LEFT JOIN
(Select max(t2.Identity_ID) Identity_ID
From MyTable t2 (nolock)
Group by t2.Unique_ID) t2 on t2.Identity_ID = t1.Identity_ID
Where t2.Unique_ID is null
Signature is NULL
Viewing 4 posts - 31 through 33 (of 33 total)
You must be logged in to reply to this topic. Login to reply