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.
| Author |
Topic |
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-07-09 : 12:12:28
|
| I have a varchar column with true or false values. The query was likeSELECT....isnull(MemberPlotLinks.Member, 'No')...And the output was True or False.Instead I want to display [Member] if it is true, nothing if false.How do I do that?Thanks. |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-07-09 : 12:15:26
|
| Select case when col1 is 'true' then Member else '' end from tableSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-07-09 : 12:26:27
|
| But I have other columns in the query likeSELECT FirstName + ' ' + LastName + ' ' + IsNull(MemberPlotLinks.Member, 'No')So, how I do it?Thanks. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-09 : 12:33:28
|
PLEASE SHOW EXAMPLE DATAANDWANTED OUTPUTThat would really help to help you  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-07-09 : 12:37:35
|
| SELECT FirstName + ' ' + LastName + ' Member: ' + IsNull(MemberPlotLinks.Member, 'No')current output: Kelly Hops Member: Truedesired output: 1. Kelly Hops [Member]2. Fred Thompson |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-09 : 12:47:01
|
Do you mean this?SELECT FirstName + ' ' + LastName + case when MemberPlotLinks.Member is null then '' when MemberPlotLinks.Member = 'false' then '' else '[Member]'end... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-07-09 : 13:35:43
|
| Thanks, its working...didn't know I can use case right after the plus. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-10 : 03:00:30
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|