When debugging a stored procedure, I usually use this piece of code below:
DELCARE @Msg varchar(30) ... SELECT @Msg = CAST(@@ROWCOUNT AS VARCHAR(10)) + ' rows affected' RAISERROR (@Msg, 0, 1) WITH NOWAIT
I use it before and after the operation, for example, to delete. I will put a number in the message to track which fragment I use in the code. This is very useful when you are dealing with a large stored procedure with a lot of lines of code.
source share