• This is a very good question, thank you. I did not have any problems answering after posting the datalength question expanding on the original question on len function by Ron Moses. It it took me a little bit of time to figure out that there are no issues with overflowing the input though. After the first 10 steps the input is simply right-padded with 10 blanks and further steps achieve nothing as there is a limit of 16 characters on the input definition, so the tight loop just keeps on going until it is killed since the queries never timeout in SSMS.

    The question very cleverly shows how easy it is to introduce the tight endless loop in T-SQL, all it takes is not to think straight for a moment.

    Oleg