VB.net SQL Check if name is within a string

Hi

I have VB.nrt code where I use the following SQL to check if a child's name is in a certain string. There is a child with the name "Nahil" but the following returns no match
Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('ABSA BANK Nahil LaherNMA',[Child Name]) > 0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
my initial though is there should be a space somewhere for example
Nahil LaherNMA

should be
Nahil Laher NMA
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi. That makes no difference unfortunately
0
plusone3055Commented:
have you run it against another name where it does return a specific  result and if so please post that
 code
so we can dig deeper  :)
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
I used the following. There are ten children with the name "Jayden". Nothing came up

Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('I think Jayden was here',[Child Name]) > 0
0
plusone3055Commented:
test this out

Select  [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] LIKE '%Jayden%'

if that works  and brings back the 10

try
Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
I tried Select Distinct [CustomerID], [BANK_REF] From [CHILDREN] Where [Child Name] = 'Jayden' and it brought back the ten
0
plusone3055Commented:
Then use

Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
The whole point of my question is finding a string within a longer string
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
This LIKE function actually does the job well. Sorry about the confusion
0
plusone3055Commented:
I thought it would.. No worries
Have a great day :)
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks again. Have a great day too
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.