separate space delimite field

  • I have a field data like this 1648 Huntingdon Pike which separet by space.

     

    I tried to use this select query to return 1648 Huntingdon

     

    select  CHARINDEX(PName, '  ' ) , PName  from DoctorMaster

     

    select  CHARINDEX(PName, space(1) ) , PName  from DoctorMaster

    I do not know why CHARINDEX(PName, '  ')  return 0.

    select substring(PName,  1, CHARINDEX(PName, space(1) ) ) , PName  from DoctorMaster

     

    I use the above substring return nothing on substring(PName,  1, CHARINDEX(PName, space(1) ) ) ,

    Thx.

     

  • You got the parameters in the CHARINDEX backwards. THe space should be the first param.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply