When there are IF branches or conditional logic, “Edit Query Text” only shows you the branches that actually executed. It’s easy to miss whole swaths of code that didn’t happen to execute one particular time.
To demo it, let’s create a simple stored procedure with an IF branch that sometimes executes, and sometimes doesn’t:
CREATE OR ALTER PROC dbo.ProcessUser @DisplayName NVARCHAR(40) AS BEGIN UPDATE dbo.Users SET Reputation = Reputation + 1 WHERE DisplayName = @DisplayName IF @@ROWCOUNT = 0 /* Uh oh, we didn’t find a user, let’s find the closest match */ UPDATE dbo.Users SET Reputation = Reputation +

