| Posted by David Portas on 09/19/05 23:58 
Thanks for posting the DDL. It does help if you include keys and constraints with your CREATE TABLE statements and post some sample data abd required
 results too. Here's my guess, hopefully it will give you a start even if it
 isn't exactly what's required.
 
 UPDATE child
 SET newcode = 10
 WHERE code = 5
 AND EXISTS
 (SELECT *
 FROM child AS C
 WHERE fk_parent_id = child.fk_parent_id
 AND code > child.code
 AND dt < child.dt) ;
 
 --
 David Portas
 SQL Server MVP
 --
  Navigation: [Reply to this message] |