title: Confused about SQL Server trigger that does an UPDATE (strange UPDATE statement format)
body: <p>The crux of my question is the following style of UPDATE statement in a trigger:</p>
  
  <pre><code>update ActualTableName 
      set X=Y 
  from inserted
  </code></pre>
  
  <p>I would have thought that this is a syntax error... the table "ActualTableName" does not appear in the "from" clause.</p>
  
  <p>So... is this just some sort of funky automatic alias "unwind" (i.e. it knows "inserted" is an alias for ActualTableName? This seems unlikely because of a later query (see below).</p>
  
  <p>Or... is there something more... like the query is expanded to:</p>
  
  <pre><code>update ActualTableName 
      set X=Y 
  from ActualTableName 
      cross join inserted
  </code></pre>
  
  <p>This also gets a bit stranger with a more complicated UPDATE that references both the inserted and deleted tables:</p>
  
  <pre><code>update ActualTableName
      set [... some assignments ...]
  from 
      inserted 
          left outer join deleted
              on inserted.Id = deleted.Id 
                 and inserted.SomeField &gt; deleted.SomeField
  where 
      inserted.Id &lt;&gt; ActualTableName.Id and 
  </code></pre>
  
  <p>This query appears to be updating records in ActualTableName that are not part of the inserted table... and this leads me to think that the actual query is:</p>
  
  <pre><code>update ActualTableName
      set [... some assignments ...]
  from 
      ActualTableName
          cross jon inserted 
          left outer join deleted
              on inserted.Id = deleted.Id 
                 and inserted.SomeField &gt; deleted.SomeField
  where 
      inserted.Id &lt;&gt; ActualTableName.Id and 
  </code></pre>
  
  <p>The books online are a bit opaque about this, and says this:</p>
  
  <blockquote>
    <p>If the object being updated is the same as the object in the FROM
    clause and there is only one reference to the object in the FROM
    clause, an object alias may or may not be specified. If the object
    being updated appears more than one time in the FROM clause, one, and
    only one, reference to the object must not specify a table alias. All
    other references to the object in the FROM clause must include an
    object alias.</p>
  </blockquote>
  
  <p>So... can anyone provide clarity as what is going on?</p>