Statements show plans that correspond to different statments

Vlady Oselsky 2016-09-15 13:59:45

This is one of my queries from SQL Saturday Presentation, after running entire query against SQL Server 2016 (13.0.1601.5) when ever selecting some of the statements it does not show execution plan and for another statements it shows plan that does not correspond to that statement.

One of the examples is IF OBJECT_ID('dbo.TableHeap') IS NOT NULL statement shows plan for UPDATE TABLE.