I\'ve come across a interesting scenario (at least for me) in a stored procedure. Would like to have experts opinion and thoughts on it.
DECLARE @loopcounter
The variable scope is the whole batch in this case a stored procedure.
It isn't re-declared every loop
So this is exactly as expected
Edit:
There is a recent blog article which is quite similar. The author was quickly corrected :-)