Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8715919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:57:37+00:00 2026-06-13T05:57:37+00:00

I have a single table for which I wish to find all the instances

  • 0

I have a single table for which I wish to find all the instances where 0 is the last character in a string field. I tried this by using two methods and they each returned different results.

This first query seemed to actually return the correct answer

select * from icd
    where CHARINDEX('0',icd,LEN(icd)) =LEN(icd) 

this one does not catch all of the answers

select * from icd
    where PATINDEX('%0%',icd) = LEN(icd)

using

select t.ICD as theCharIndex,x.ICD as thePatIndex from
(

select * from icd
    where CHARINDEX('0',icd,LEN(icd)) =LEN(icd) 
) t
left join
(
select * from icd
    where PATINDEX('%0%',icd) = LEN(icd)
) x on x.ICD=t.ICD
where x.ICD is null

I found the set of data that CHARINDEX picked up that PATINDEX did not. I even did

update icd
set ICD=RTRIM(icd)

Why would PATINDEX indiscriminately leave out some rows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:57:38+00:00Added an answer on June 13, 2026 at 5:57 am

    Because you have a 0 somewhere before the end.
    Change PATINDEX('%0%',icd) to PATINDEX('%0',icd)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single column table which looks like this: Gaming | Austria |
I have a table which have a single field. and it have a values
I have a single product table with multiple fields which contain user evaluations of
I have a table which needs to be scrollable within a single page. I've
I currently have a table which only has a single editable column. I have
I have a huge access mdb file which contains a single table with 20-30
I have static data in a single table which I must serialize. I have
I have a table T (structure below) which initially contains all-NULL values in an
I have a single table varchar, int, int like this: OS MinSP MaxSP --
I have two applications, one updates a single table which has constant number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.