I was in a database class the other night and we noticed that the following code seemed to work, but we could not logically understand why.
DECLARE @counter integer
SET @counter = 42
WHILE @counter < 52
BEGIN
set @counter = @counter+++++ + 1
PRINT 'The counter is ' + cast(@counter as char)
END
We realized that we could add any number of +'s on to our @counter variable, and SSMS does not seem to care, even though it does not match the original variable. Anybody happen to know why this works?