Posted by imani_technology_spam@yahoo.com on 09/20/05 19:10
Thank you for the information. I'm wondering how this would work as a
SELECT statement. Also, let's assume there is a foreign key constraint
on fk_parent_id. And the pk field is a primary key.
David Portas wrote:
> 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]
|