declare @counter int set @counter = 1 while @counter < 100000 begin insert into Test1 values (@counter, 'Counter' + cast(@counter as char(10)) insert into Test2 values (@counter, @counter, @counter,'Counter' + cast(@counter as varchar(10)) set @counter = @counter +1 endafter the first cast operation the type of the Counter variable actually changes from int to char and thus the second insert fails.