• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

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

0
avoorheis
Asked:
avoorheis
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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.
0
 
avoorheisAuthor Commented:
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?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I still don't see the issue...
0
 
avoorheisAuthor Commented:
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.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't see any issue, specifically if you tested that it works.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now