da-zero (4/12/2010)
A small question:isn't the variable @InputStr stored somewhere? As the loop goes on forever, at some point in time that variable will become too large to reside in memory/physical location. So some sort of out of memory exception has to take place, right?
Try this to see whats happening under the hoods:
CREATE PROC #FixedLength
@InputStr VARCHAR(16)
AS
WHILE LEN(@InputStr) < 16
BEGIN
SELECT @InputStr = @InputStr + ' '
PRINT '<' + @InputStr + '>'
END
RETURN @InputStr
GO
EXEC #FixedLength '154620';
GO
You need to cancel after one or two seconds to see the results.
Best Regards,
Chris Büttner