------------------------------------------------------- -- To setup the repro run part between these lines -- first. use Northgale go if object_id('P') IS NULL EXEC ('CREATE PROC P AS PRINT 1') go alter proc P ( @i int, @oid int ) as declare @x int = @@spid select @i, @x, convert(int, context_info()), OrderID, CustomerID as cn from Orders where @oid = OrderID option (recompile); go create table T2 ( spid int default @@spid, retspid int, real_iter int, retiter int, retcontxt int, OrderID int, v nvarchar(50), ); ------------------------------------------------------- -- Then run the script recompile_bug_exploit.sql in two -- or more query windows. The run the query below. With -- correct execution the query should not return any rows -- at all. (Note that if will only see rows returned if -- you are on SQL 2008 RTM.) select * FROM T2 where real_iter <> retiter order by spid, real_iter