What’s better to use:
INSERT #tableN (ID,NAME,Value)
SELECT 1, 'a', SUM(a) FROM tab UNION ALL
SELECT 2, 'b', SUM(b) FROM tab UNION ALL
SELECT 3, 'c', SUM(c) FROM tab UNION ALL
SELECT 4, 'd', SUM(d) FROM tab UNION ALL
SELECT 5, 'e', SUM(e) FROM tab UNION ALL
...
SELECT 3000, 'a3000', SUM(a3001) FROM tab UNION ALL
SELECT 3001, 'a3001', SUM(a3001) FROM tab
or
INSERT #tableN (ID,NAME,Value)
SELECT 1 , 'a', SUM(a)
FROM tab
INSERT #tableN (ID,NAME,Value)
SELECT 2, 'b', SUM(b)
FROM tab
INSERT #tableN (ID,NAME,Value)
SELECT 3, 'c', SUM(c)
FROM tab
INSERT #tableN (ID,NAME,Value)
SELECT 4, 'd', SUM(d)
FROM tab
...
INSERT #tableN (ID,NAME,Value)
SELECT 3001, 'a30001', SUM(a3001)
FROM tab
It seems like you’re wanting to rotate the table to create a new table. There are tidier ways to do this than writing (or generating) all that SQL. Look into PIVOT and UNPIVOT especially. It allows you to convert the columns into rows, and provide filtering on the intermediate result set. You may need to find some more resources in relation to pivoting, but the link above should jump start you well enough if you decide to consider this option.