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-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
Go to Top of Page

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.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

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.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.

Go to Top of Page

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!

Tim

quote:
Originally posted by jsmith8858

read about the CASE statement in books on-line. you also might use the ISNULL() function.


- Jeff

Go to Top of Page
   

- Advertisement -