Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Alternate Columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-10 : 09:22:42
bungie writes "Is it possible (other than through dynamic sql) to retrieve different columns based on a parameter?

In this case, I'd like to select a description column based on a language parameter.

eg:
Declare @Language int
@Language = 1
SELECT ID, Iif(@language=0,EnglishDesc, FrenchDesc) as Description FROM table.

where EnglishDesc, and FrenchDesc are column within the table.

I've tried using CASE but that will generate a syntax error, it can only have affect on the results side of the equation.

I would think, and even wish, that you could specify a base column with an offset.. a relative column!

eg:
Declare @Language int
@Language = 1
SELECT ID, EnglishDesc + @Language as Description FROM table.

Sort of accessing directly through the ordinals.

Any help would be most appreciated.

-Steve"
   

- Advertisement -