Replace always replacing null values
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-05-03T18:50:16Z
Indexed on
2010/05/03
19:08 UTC
Read the original article
Hit count: 186
sql-server-2000
Why does
left(FIELD, replace(nullif(charindex('-', FIELD), 0), null, len(FIELD)))
always return null? The idea behind the query is that if charindex() returns 0, then convert the results into null, then convert the null into the length of the field. So if '-' does not exist, show the whole string. For some reason it makes every row equal null.
Thank you.
© Stack Overflow or respective owner