Re: T-SQL Update .. from

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 07/17/04


Date: Sat, 17 Jul 2004 20:46:26 +0100


> while neither the T-SQL nor ANSI query has an explicit WHERE clause, the
> T-SQL UPDATE .. FROM query limits the update to target table rows that
> appear in the implicit join. If that's not all of the rows, as is often
> the case, the ANSI rewrite updates the correct rows and also NULLs out
> information in every other row.

It's true that in that sense the ANSI syntax is less concise. You have to
specify the "join" criteria twice to achieve the same functionality as
UPDATE FROM ... INNER JOIN. So the programmer can still screw up but at
least she will do so in manner that is deterministic!

> update T set
> columnA = U.columnA
> from T, U
> where U.key = T.key

The FROM syntax is truly a bad Friday afternoon piece of work. SQL Server,
Access and Visual Foxpro all have proprietary methods for multi-table UPDATE
statements but most frustrating of all, they are all different! (although
the VFP9 Beta at last supports ANSI UPDATEs :).

For me the worst is that UPDATEs with ill-formed JOIN criteria will work
with no indication that anything is wrong. You just know that not everyone
is savvy enough to pick the problem up in testing. At the very least it
should raise a warning condition - something that could surely be fixed
without breaking legacy code or incurring an unacceptable performance
overhead.

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: Use ANSI Join or Old Style Join?
    ... Would you use ANSI style table joining or the 'old ... you specify the join as INNER JOIN or in the WHERE clause. ... Whether and when to specify join conditions using the INNER ... Make sure you specify your SQL Server version and service ...
    (comp.databases.ms-sqlserver)
  • Re: Oracle licence question
    ... SS isn't completely ANSI 92 compliant at ... So, I guess let me rephrase the question - does Oracle have ENTRY, ... INTERMEDIATE and FULL compliance to FIPS 127-2 because I can only find ... SQL Server MVP ...
    (comp.databases.oracle.server)
  • Re: Help on sppeding up a 15,000 line batch process
    ... Since everything's so prorietary, the only interface I ... > SQL server in ANSI format and never use unicode... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Oracle licence question
    ... I did and I couldn't find the citation, which is why I asked you for it. ... I want to check what level of ANSI compliance MS claims, to validate your claim that their implementation of SQL is somehow more the ANSI standard compliant than Oracle's. ... Oracle - http://www.itjobswatch.co.uk/jobs/uk/oracle.do ... SQL Server - http://www.itjobswatch.co.uk/jobs/uk/sql%20server%20dba.do ...
    (comp.databases.oracle.server)
  • Re: Oracle licence question
    ... What level of ANSI 92 or didn't you know there are different levels? ... SQL Server - http://www.itjobswatch.co.uk/jobs/uk/sql%20server%20dba.do ... you ought to compare Oracle DBA with SQL Server DBA and ... starts to get a bit interesting and bias toward Oracle starts to be shown, ...
    (comp.databases.oracle.server)