December 13, 2008 at 8:01 pm
i,
i would like to change the value of column names in the where cluse.
for ex.
where (case when @Store ='Country' then 'Country'
when @Store ='State' then 'State'
when @Store ='City' then 'City'
when @Store ='Region' then 'Region'
when @Store ='Store Name' then 'StoreName'
end)
= @StoreAttribute
i want to change the columnnames on runtime
when i compile this i'm not getting any errors but i'm getting null values.
how to solve this any idea.
Thanks,
Regards
Viji
December 13, 2008 at 10:23 pm
Try it like this:
where (case when @Store ='Country' then [Country]
when @Store ='State' then [State]
when @Store ='City' then [City]
when @Store ='Region' then [Region]
when @Store ='Store Name' then [StoreName]
end)
= @StoreAttribute
In order for this to work, all of the columns must be of compatible data types.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy