Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to select alternate column if first choice is NULL

Status
Not open for further replies.

warelock

IS-IT--Management
Aug 16, 2005
12
US
I'm working with SQL Server 2000 on Windows XP. IN one query, I want to select a federal tax ID number for each record, but if that tax ID number is NULL, I need to select a different SS ID column. I don't know how to do this !

Can you help me please ?

Appreciate any help you can give. Thanks !
 
Select [!]Coalesce[/!](FedTaxId, SS_ID)

Look it up in Books On Line.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thank you, gmmmastros !

BTW, what are Books OnLine ? Yes, I may be an idiot.
 
Book On Line are the help files for T-SQL.

When you are using the query analyzer, you can press F1 for help. Unfortunately, this is help for USING Query Analyzer. To get help on SQL Syntax, press SHIFT-F1 in the query analyzer.

For example, type Coalesce in to Query Anaylyzer. Make sure the cursor is somewhere within that word, and then press Shift-F1 on your keyboard. Books On Line will open with Coalesce highlighted.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Also, please take a look at this FAQ's: faq183-689


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
select COALESCE(taxIDnumber,differentSSIDcolumn), ... FROM whatevertables

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top