Page 1 of 1

PATINDEX Equivalent

Posted: Mon Nov 03, 2008 5:49 pm
by DeepakCorning
Is there an equivalent for the MSSQL Patindex in Datastage?

Requirement is to convert like the following --


Source Target

ABC-DEF ABC
EFGHI-KL EFGHI
A-B A
-JKL NULL

(substring from 1 till it finds the first occurence of "-").

Thanks !!!

Posted: Mon Nov 03, 2008 5:56 pm
by Mike
Use the index function to locate the first "-" character, then search the forum for one of many ways to extract a substring from a string.

Actually, the Field function is probably even easier.

Mike

Posted: Mon Nov 03, 2008 6:11 pm
by DeepakCorning
Yes , I think I got it --

FIELD (COLUMN , "-" , 1) will solve it...