I'm not sure you can do a case statement like that (meaning, combine a variable and column). For example, i tried the following:
DECLARE @var varchar(20), @val varchar(20)
SET @var = 'Global'
SELECT @val =
case
when @var = 'U.S.' then 'U.S.'
when 'Asia' then 'Asia'
when 'Europe' then "'Western Europe', 'Eastern Europe'"
when @var = 'Global' then 'Global'
when 'ROW' then "'Non-U.S.', 'Latin America'"
else @var
end
print @val
That didn't work. The only way to successfully get it to work was to do something like:
SELECT @val =
case
when @var = 'U.S.' then 'U.S.'
when @var = 'Asia' then 'Asia'
when @var = 'Europe' then "'Western Europe', 'Eastern Europe'"
when @var = 'Global' then 'Global'
when @var = 'ROW' then "'Non-U.S.', 'Latin America'"
else @var
end
OR
case
when 'U.S.' = 'U.S.' then 'U.S.'
when 'Asia' then 'Asia'
when 'Europe' then "'Western Europe', 'Eastern Europe'"
when 'Global' = 'Global' then 'Global'
when 'ROW' then "'Non-U.S.', 'Latin America'"
else comp.Geofocus
end
Hope this helps...
Scott Klein
Author - Professional SQL Server 2005 XML
http://www.wrox.com/WileyCDA/WroxTit...764597922.html