[thelist] MSSQL character weirdness

Mark Rees mrees at itsagoodprice.com
Mon Sep 19 11:27:20 CDT 2005


Please ignore, I have read the manual again and the arguments for CHARINDEX
were the wrong way around.

SELECT CHARINDEX(char(32),cm.Name,1) FROM TABLE produces the desired result

Sorry

> Hello
>
> In this table, Name holds a full name, like "Graham Barrow"
>
> I'm trying to split it on the first space. I thought this would be easy.
> However this query
>
>
> SELECT
> ASCII(SUBSTRING(cm.Name,6,1)),
> CHARINDEX(cm.Name,char(32),1) FROM TABLE
>
> produces the following output:
>
> 32 0
> 32 0
> 80 0
> 32 0
> 32 0
>
> etc
>
> So ASCII says that char(32) is present, but CHARINDEX says different. I
see
> the same behaviour if I use a space like so ' '
>
> Can anyone shed any light on this?
>
> Thanks in advance for your help




More information about the thelist mailing list