title: Delete from CTE with join
body: <p>I'm  trying to implement a FIFO queue using a sql table. </p>
  
  <p>I have the following SQL (modified for posting), the join and param usage are important to the way this process works. </p>
  
  <pre><code>With cte as (
     select top(1) q.* from queue q with (readpast)
     inner join MyTable a on q.id = a.myTableID AND myTable.procID = @myParam
     order by q.Data asc
  )
  delete from cte
      output
        deleted.ID,
        deleted.col1
  </code></pre>
  
  <p>running this statement returns an error 'View or function 'cte' is not updatable because the modification affects multiple base tables.' </p>
  
  <p>I understand why the error is thrown, what I can't figure out is how to fix it. Any advice would be much appreciated! </p>