SQL Server 2016 – Does Cursor Use Old Query After Stored Procedure Alteration?

cursorsddlsql serversql-server-2016stored-procedures

If a stored procedure (or view) is currently in use within a long running cursor, and I alter that stored procedure, will the cursor continue using the old instance of the stored procedure until the cursor is finished?

Best Answer

So per @LowlyDBA's suggestion I decided to test this for myself (to a degree). I was actually in the middle of debugging a hot production issue so couldn't really stop to write out the code for a test case. But the code I'm debugging is this scenario. So I made my update to the procedure and looked at the running queries and saw the query text changed from before and after my change to the procedure as the cursor continued to iterate.