CREATE TABLE TABLE_0 ( ID INT ) CREATE TABLE TABLE_1 ( ID INT ) CREATE TABLE TABLE_2 ( ID INT ) GO DECLARE @NUM INT = 1; WHILE (@NUM < 100) BEGIN DECLARE @SQL NVARCHAR(500) = N'INSERT INTO TABLE_' + CONVERT(NVARCHAR(50),@NUM % 3) + ' VALUES(' + CONVERT(nvarchar(50),@NUM) + ')'; print @sql EXECUTE sp_executesql @SQL SET @NUM = @NUM + 1 END GO SELECT * FROM TABLE_0 SELECT * FROM TABLE_1 SELECT * FROM TABLE_2 SELECT COUNT(1) FROM TABLE_0 SELECT COUNT(1) FROM TABLE_1 SELECT COUNT(1) FROM TABLE_2