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)
 Use of Logic in Select Statement to create column values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-02 : 07:10:25
Tim writes "Hi,

I'm trying to return a value in a column based on the value in another column. I've tried combining the values in the two fields, but one of them can contain nulls,and adding a null to another field returns a null.

t1.Live = Char 1 ['Y',Null]
t2.Login_name = Char 12 ['Joe', 'Mike'...]

For example, if live = 'Y', I want to return a login_name of 'XJoe' otherwise, I want to return a login_name of 'Joe'.

This design is not optimal, but I have to work with existing data structures and code.

Any ideas?

Thanks,

Tim"

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2004-06-02 : 07:21:25
[code]
... case when live = 'Y' then 'X' else '' end + login_name ...
[/code]
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-02 : 07:23:11
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=35705

Go to Top of Page
   

- Advertisement -