Link to home
Start Free TrialLog in
Avatar of avoorheis
avoorheis

asked on

how to handle single quote in PATINDEX

I'm trying to parse the names that come in like Doe, John to John Doe and we now have a name like Cox, J'son (which I think is giving me a problem). Is there something I can do to allow quotes in the names?
thanks for your help
RIGHT(dbo.udfTasksPrimaryClosed.ClosedByNameFull,LEN(dbo.udfTasksPrimaryClosed.ClosedByNameFull)-PATINDEX('%,%',dbo.udfTasksPrimaryClosed.ClosedByNameFull)-1) + ' ' +
   SUBSTRING(dbo.udfTasksPrimaryClosed.ClosedByNameFull,1,PATINDEX('%,%',dbo.udfTasksPrimaryClosed.ClosedByNameFull)-1) AS ClosedBy,
   Count(dbo.udfTasksPrimaryClosed.TaskNumber) as ClosedCount,
   AVG(dbo.fn_WorkDays([Created], [Closed])) as ClosedDays

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

please confirm that you are using MS SQL Server and not MySQL ...

now, the code you posted in itself is not a problem in regards to the quotes, so it must be some other code.
please post the relevant code.
Avatar of avoorheis
avoorheis

ASKER

sorry, there was another issue.

However, it is MS SQL and I'm converting a name field from Last, First to First Last (so just the first 2 lines of code, mistakenly copied an additional 2 lines). Seems like a lot to do this, but, I'm a noob...is there a better way?
I still don't see the issue...
I should have been more clear...it's working ok the way it is and does make the swap last/first (there was another issue).
I thought since I had already posted, you might comment on whether the sql that I've used is the best approach for doing what I want.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial