Hi,
I'm using SQL 2005.
Is it possible to replace a column with a parameter in SQL?
I have a table which has 12 columns a1, a2,...,a12
I now want to replace that number by a parameter I chose before running the query. (I'm building a DB query in Excel 2007 with paramters)
So for example if the parameter I chose is 1 than the SQL query should be: SELECT a1 FROM table.
But if the parameter is 2 the statement should read: SELECT a1+a2 FROM table.
Paramter 3: SELECT a1+a2+a3 FROM table an so on.
Is that possible at all?
I'm using SQL 2005.
Is it possible to replace a column with a parameter in SQL?
I have a table which has 12 columns a1, a2,...,a12
I now want to replace that number by a parameter I chose before running the query. (I'm building a DB query in Excel 2007 with paramters)
So for example if the parameter I chose is 1 than the SQL query should be: SELECT a1 FROM table.
But if the parameter is 2 the statement should read: SELECT a1+a2 FROM table.
Paramter 3: SELECT a1+a2+a3 FROM table an so on.
Is that possible at all?