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 Rhinorhino 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

  • Thread starter Thread starter gc
  • Start date Start date
Status
Not open for further replies.

gc

MIS
Joined
Mar 8, 2001
Messages
68
Location
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