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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-06-01 : 07:37:00
|
| 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" |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-06-01 : 07:48:22
|
| read about the CASE statement in books on-line. you also might use the ISNULL() function.- Jeff |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-01 : 08:14:04
|
| Is this SQL Server or some other random DBMS? It looks like and alien.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
Timj
Starting Member
3 Posts |
Posted - 2004-06-01 : 09:27:39
|
Yes, It's SQL Server 2000.quote: Originally posted by derrickleggett Is this SQL Server or some other random DBMS? It looks like and alien.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA.
|
 |
|
|
Timj
Starting Member
3 Posts |
Posted - 2004-06-01 : 09:28:42
|
Jeff,Thanks. I did figure out how to do this with the case statement. Many thanks!Timquote: Originally posted by jsmith8858 read about the CASE statement in books on-line. you also might use the ISNULL() function.- Jeff
|
 |
|
|
|
|
|
|
|