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

Hi! I got syntex error message whe

Status
Not open for further replies.

gc

MIS
Mar 8, 2001
68
US
Hi!
I got syntex error message when try to run the code:

SELECT
CASE
WHEN NOT ISNUMERIC(LEFT(MRN,1)) THEN MRN
WHEN NOT ISNUMERIC(LEFT(RIGHT(MRN,2),1)) THEN RIGHT(MRN,2)
ELSE RIGHT(MRN,1)
END AS Code
FROM abo.tblPatients

The error message is: Incorrect syntax near the keyword "THEN" on the second line

Please tell me what's wrong?
Thanks in advance!
George
 
SQL Server will not evaluate a boolean expression this way.
Try:

SELECT
CASE
WHEN ISNUMERIC(LEFT(MRN,1)) = 0 THEN MRN
WHEN ISNUMERIC(LEFT(RIGHT(MRN,2),1)) = 0 THEN RIGHT(MRN,2)
ELSE RIGHT(MRN,1)
END AS Code
FROM abo.tblPatients JHall
 
Hi! J,
Thank you very much!
It's working now.
George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top