Yup, something very similar to that.
Now, once you have a set of the columns, you'd need to parse through them to generate a long script.
Again, I'm more tempted to open up that table that holds the necessary columns through .NET. T-SQL isn't great at this sort of things.... however, you "could" use the T-SQL "for xml" capability. The following example is one I use to show people how to take a bunch of rows and generate a single comma-separated string. This might or might not apply to what you're doing.....but here's an example...
declare @ShipMethodIDList nvarchar(1000)
set @ShipMethodIDList =
stuff ( ( select distinct ',[' +
cast(ShipMethodID as varchar(100)) + ']'
from Purchasing.ShipMethod
for xml path('') ), 1, 1, '')
Though again, I'd be more tempted to write a short .NET script (or obviously, a fox script as well)
Again, thinking out loud, but hopefully this helps a bit.