Hello,Perhaps something like this;--create temp global containerscreate table ##Table_1 (margin int, adj int)create table ##Table_2 (margin int, adj int)create table ##Table_3 (margin int, adj int)create table ##Table_4 (margin int, adj int)create table ##Table_5 (margin int, adj int)create table ##Results (tableName varchar(20), marginCt int)insert ##Table_1 select 1,0 union all select 2,0insert ##Table_2 select 2,0 union all select 2,0insert ##Table_3 select 3,0 union all select 2,1insert ##Table_4 select 4,0 union all select 2,0insert ##Table_5 select 5,1 union all select 2,1--declare varsdeclare @sql varchar(1000), @ct tinyint, @maxCt tinyint--init vars SELECT @ct = 1, @maxCt = 5--perform loopWHILE (@ct <= @maxCt)BEGIN SET @sql = 'INSERT ##Results (tableName, marginCt) SELECT ''##Table_' + CAST(@ct AS VARCHAR(10)) + ''', COUNT(margin) FROM ##Table_' + CAST(@ct AS VARCHAR(10)) + ' WHERE adj <> 1' EXEC(@sql) SET @ct+=1END --display resultsSELECT * FROM ##Results--clean up example containersdrop table ##Table_1, ##Table_2, ##Table_3, ##Table_4, ##Table_5--clean up results containersdrop table ##Results