Re: Update & Delete
From: Jason Williams (jasonwilliams_at_msn.com)
Date: 03/11/04
- Next message: shank: "temp tables"
- Previous message: Tom Moreau: "Re: Top x Percent"
- In reply to: Joe Celko: "Re: Update & Delete"
- Next in thread: Joe Celko: "Re: Update & Delete"
- Reply: Joe Celko: "Re: Update & Delete"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Mar 2004 19:42:17 -0500
Thanks to both of you,
I clearly have a long way to go, and the help is appreciated. Any books
and/or courses you recommend?
Jason
"Joe Celko" <joe.celko@northface.edu> wrote in message
news:e6GWR0vBEHA.1452@TK2MSFTNGP09.phx.gbl...
> >> update a column in table "A" from a column in table "B", and then
> delete the record [sic] in table "B". <<
>
> Since you area newbie, you might want to learn Standard SQL syntax; the
> proprietary one you used ports to a few other products and to earlier
> versions of Sybase/SQL Server, but with different semantics! The worst
> possible situation for maintaining code.
>
> The short answer is do it in a procedure, somethign liie this:
>
> BEGIN
> UPDATE TableA
> SET colA
> = (SELECT colB
> FROM TableB
> WHERE TableA.relatedA = TableB.relatedB);
> DELETE FROM TableB
> WHERE colB
> IN (SELECT colA FROM TableA);
> END;
>
> --CELKO--
> ===========================
> Please post DDL, so that people do not have to guess what the keys,
> constraints, Declarative Referential Integrity, datatypes, etc. in your
> schema are.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
- Next message: shank: "temp tables"
- Previous message: Tom Moreau: "Re: Top x Percent"
- In reply to: Joe Celko: "Re: Update & Delete"
- Next in thread: Joe Celko: "Re: Update & Delete"
- Reply: Joe Celko: "Re: Update & Delete"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|