x
login about faq Site discussion (meta-askssc)

Search for Characters in SQL server 2000 or 2005

Please guide me below mentioned problem

String1 = ÁĚĎ String2 = PQĎ

I need to find out whether any of the characters in string1 appears in string2. My fuction should exit the loop at the first occurance of any of the string1 character in string2. I do not want to process each of the character in string1 in a loop as i have to process millions of records in the database. Can anyone guide me what sql statement can be written in sql server 2000 or sql server 2005.

With Regards

Novice

more ▼

asked Nov 06 '09 at 06:30 AM in Default

SQLserver_novice gravatar image

SQLserver_novice
113 6 6 7

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first
SELECT PATINDEX('%[abc]%', 'This is a test')

That will return 9 - the 1-based index of the first occurrance of any of the letters a, b or c

more ▼

answered Nov 06 '09 at 07:46 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

(comments are locked)
10|1200 characters needed characters left

Have you thought of using full-text indexing and using the CONTAINS function?

more ▼

answered Nov 06 '09 at 07:30 AM

Mark Allison gravatar image

Mark Allison
479 1 1 4

(comments are locked)
10|1200 characters needed characters left

I know it's an old post, Ben, but did either of these answers solve your problem?

more ▼

answered Mar 07 '10 at 01:17 PM

Jeff Moden gravatar image

Jeff Moden
1k 1 3

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1834
x914
x454

asked: Nov 06 '09 at 06:30 AM

Seen: 1182 times

Last Updated: Nov 06 '09 at 06:50 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.