Search code examples
crystal-reportssqlcommandcharindex

FINDING SPACES with charindex in sql command crystal reports


I have this code to find a space in the sql command to and return it with the database fields in crystal reports, but the charindex keeps returning zeros.

SELECT ALLEGATION, CHARINDEX(ALLEGATION, ' ', 1) AS SPACE
FROM ALLEGATIONS

WHY DOES IT KEEP SAYING 0?


Solution

  • It should be the opposite order:

    SELECT ALLEGATION, CHARINDEX(' ', ALLEGATION, 1) AS SPACE FROM ALLEGATIONS