View Full Version : get substrings but disregard blank entries


ew1
04-12-2005, 12:13 PM
Hi, I'm trying to create a column from an existing column using a Instr function but I get errors for rows that have blank entries.

SELECT
PERSON.[Preferred Certificate Name],

Trim(Right([Preferred Certificate Name],(Len([Preferred Certificate Name])-Len([preferredFirstName])))) AS preferredLastName,

Trim(Left([Preferred Certificate Name],InStr([Preferred Certificate Name]," ")-1)) AS preferredFirstName,

FROM PERSON
WITH OWNERACCESS OPTION;

How can I fix this??

TIA!

Jon K
04-12-2005, 05:37 PM
SELECT PERSON.[Preferred Certificate Name],

IIf(IsNull([Preferred Certificate Name]), Null, Trim(Right([Preferred Certificate Name], (Len([Preferred Certificate Name])-Len([preferredFirstName]))))) AS preferredLastName,

IIf(IsNull([Preferred Certificate Name]), Null, Trim(Left([Preferred Certificate Name], InStr([Preferred Certificate Name]," ")-1))) AS preferredFirstName

FROM PERSON
WITH OWNERACCESS OPTION;

.