Okay, here is goes. I just figured out how to 'select' two columns from the same one column with different requirements. Now, I would like to create dynamic columns and as many as I want. For example, if I type in "exec SP '5','1,2,34,52,656'" (5 for the number of variables and the second string is which variables) It will gives me columns that satisfied the requirements. The results of the table would be: (with the first columns being the common requirement) Variance PopTotal1 Poptotal2 Poptotal34 PopTotal52 PopTotal656 1 x x x x x 2 x x x x x Here is the code for creating two columns only. DECLARE @Var4 TABLE (RowNr INT IDENTITY(1,1), PopTotal INT) DECLARE @Var6 TABLE (RowNr INT IDENTITY(1,1), PopTotal INT) INSERT INTO @Var4 (PopTotal) SELECT PopTotal FROM table WHERE revid = 11 AND variance = 4 ORDER BY PopTotal INSERT INTO @Var6 (PopTotal) SELECT PopTotal FROM table WHERE revid = 11 AND variance = 6 ORDER BY PopTotal SELECT V4.PopTotal, V6.PopTotal FROM @Var4 v4 FULL JOIN @Var6 v6 ON v4.RowNr = v6.RowNr ORDER BY ISNULL(v4.RowNr, v6.RowNr), ISNULL(v6.RowNr, v4.RowNr) How do I edit this to create as many column as I want?