SQLTeam.com | Weblogs | Forums

Is there a 'For each Column' Loop?


I want to create a table like:

Col1 Col2
ValueCol1-1 ValueCol2-1
ValueCol1-2 ValueCol2-2

In other words, I want to create a table with all the columns of a Table1, and in each table, I want to populate the top 100 distinct values of that column. If there are less distinct values, the column will be shorter than the rest of course.

Is that possible? I wouldn't mind to use Excel to finalise the view.


Your question title is :slight_smile:
"Is there a ‘For each Column’ Loop?"

The rest of the question has nothing to do with loops. and very hard to understand. Please clarify?

idea number 1
create a row number and post fix it ..