Select Column Index in Transact-SQL
Posted on 2005-03-17
Does anybody know of a way to select the columns based on the column index in transact-sql. Much like if you were going to select a row from a resultset in asp or java, like myResultSet("column_1") or myResultSet(0)<--This is what I want. I'm trying to stay away from building a sql string in a stored procedure and executing it, because I know it has to compile the string statement before it executes, and one of the benefits of a stored procedure is that its already compiled.
The reason is the user wants to be able to view specific rows based on numeric data being passed in. For an example, if the user passes in 1,3,5, I would only select the first column index, the third column index and the fifth column index.
Thanks for your anticipated help...