Re: common UPDATE syntax for SqlServer and Oracle
Date: Fri, 26 Nov 2004 11:01:39 +0100
Message-ID: <41a6fed9$0$78279$e4fe514c_at_news.xs4all.nl>
But that no standard SqlServer syntax as far as I know.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas_at_acm.org> wrote in message
news:qoednbGWLZwC-TvcRVn-1A_at_giganews.com...
> The ANSI Standard syntax supported by both products is
>
> UPDATE Table1
> SET city_id =
> (SELECT T2.id
> FROM Table2 AS T2
> WHERE T2.city = Table1.city) ;
>
> Depending on requirements you may want to include a WHERE EXISTS
> (equivalent to the proprietary INNER JOIN syntax)
>
> UPDATE Table1
> SET city_id =
> (SELECT T2.id
> FROM Table2 AS T2
> WHERE T2.city = Table1.city)
> WHERE EXISTS
> (SELECT *
> FROM Table2 AS T2
> WHERE T2.city = Table1.city) ;
>
> --
> David Portas
> SQL Server MVP
> --
>
>
Received on Fri Nov 26 2004 - 11:01:39 CET