DECLARE @i INT ,@j INT SET @i=1 set @j=1 WHILE @i<11 BEGIN WHILE @j<20 IF (LEN(@i)=1) BEGIN IF (LEN(@j)=1) BEGIN PRINT '00'+CAST(@i AS VARCHAR)+'0'+CAST(@j AS VARCHAR) set @j=@j+1 END ELSE BEGIN PRINT '00'+CAST(@i AS VARCHAR)+CAST(@j AS VARCHAR) set @j=@j+1 END END ELSE IF (LEN(@i)=2) BEGIN IF (LEN(@j)=1) BEGIN PRINT '0'+CAST(@i AS VARCHAR)+'0'+CAST(@j AS VARCHAR) set @j=@j+1 END ELSE BEGIN PRINT '0'+CAST(@i AS VARCHAR)+CAST(@j AS VARCHAR) set @j=@j+1 END END ELSE IF (LEN(@i)=3) BEGIN IF (LEN(@j)=1) BEGIN PRINT CAST(@i AS VARCHAR)+'0'+CAST(@j AS VARCHAR) set @j=@j+1 END ELSE BEGIN PRINT CAST(@i AS VARCHAR)+CAST(@j AS VARCHAR) set @j=@j+1 END END set @j=1 set @i=@i+1 END