baylar
asked on
sql left and charindexfunction
Can anyone please tell why this is erroring out
select
case
when isnumeric(left('2022AVEQEN SLEY',case when charindex(char(32),'2022AV EQENSLEY')
=0 then 2
else charindex(char(32),'2022AV EQENSLEY') end -1)) = 1
then left('2022AVEQENSLEY',char index(char (32),'2022 AVEQENSLEY ')-1)
else replace(replace('2022AVEQE NSLEY',cha r(32),''), '.','')
end
select
case
when isnumeric(left('2022AVEQEN
=0 then 2
else charindex(char(32),'2022AV
then left('2022AVEQENSLEY',char
else replace(replace('2022AVEQE
end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome works the way I want.
Thanks
Thanks
This returns 0
charindex(char(32),'2022AV
Then you actually reduce it by -1
else charindex(char(32),'2022AV
You can not pass -1 to CHARINDEX function