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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TSQL Syntax help

Status
Not open for further replies.

MasterPO

Programmer
Oct 10, 2002
51
0
0
US
Good morning all...
I need help with the syntax for a Select statement.

Table = AROPNFIL
Fields = Doc_Type, Apply_To_No, Reference

I want to select the Doc_Type and (when Reference field is Numeric, choose Reference field, else choose Apply_To_No field).

All my attempts at 'If...then' and 'Case When IsNumeric...' have failed! Help!
 
How does this work?

Code:
SELECT Doc_Type
  , CASE IsNumeric(Reference)
       WHEN 1 THEN Reference
       ELSE Apply_To_No
    END AS Field2
FROM AROPNFIL


--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top