473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Searching character data using like

Hello All,

SQL 2000, case insensitive database

I have a situation where I need to find abbreviations in the rows in a
table. The rule i came up is, get all the rows from the table where
there is more than one character is capitalized consequtively eg.
"USA", "TIMS", "AIR"

Here is the sample data:

create table test (mystring varchar(100))
go
insert into test (mystring) values ('I live in USA')
insert into test (mystring) values ('this is a test row. usa
(abbreviated wrongly).')
go

--expected result set
mystring
----------------------
I live in USA

Here is the query which I tried.
select * from test where mystring collate SQL_Latin1_General_CP1_CS_AS
like '%[A-Z][A-Z]%'

But the above query returns both the records. Any help?

Thanks
Jul 20 '05 #1
2 7984
That's strange, I get the same result. However, if I change the query
(see below), I get the correct results (run on a database with
SQL_Latin1_General_CP1_CS_AS collation)

select * from test where mystring like
'%[ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZ]%'

Gert-Jan
Google User wrote:

Hello All,

SQL 2000, case insensitive database

I have a situation where I need to find abbreviations in the rows in a
table. The rule i came up is, get all the rows from the table where
there is more than one character is capitalized consequtively eg.
"USA", "TIMS", "AIR"

Here is the sample data:

create table test (mystring varchar(100))
go
insert into test (mystring) values ('I live in USA')
insert into test (mystring) values ('this is a test row. usa
(abbreviated wrongly).')
go

--expected result set
mystring
----------------------
I live in USA

Here is the query which I tried.
select * from test where mystring collate SQL_Latin1_General_CP1_CS_AS
like '%[A-Z][A-Z]%'

But the above query returns both the records. Any help?

Thanks

Jul 20 '05 #2
Thanks..
Both the the solutions worked fine. I was playing around with the
expression after I posted the message. I got it working as per
Gert-Jan solution even before the post got appeared in the news group.
I will change according to Sommars solution since it is more straight
forward. Thanks again for both of you.

Erland Sommarskog <so****@algonet.se> wrote in message news:<Xn**********************@127.0.0.1>...
Google User (us*********@hotmail.com) writes:
Here is the query which I tried.
select * from test where mystring collate SQL_Latin1_General_CP1_CS_AS
like '%[A-Z][A-Z]%'

But the above query returns both the records. Any help?


This is because the range A-Z includes all characters in that range,
and SQL_Latin1_General_CP1_CS_AS is not ASCII, but the order is
AaBb....

This query cuts it:

select * from test where mystring
like '%[A-Z][A-Z]%' collate Latin1_General_BIN

I've chosen a binary collation. Also I've move the COLLATE expresion
to the search pattern, although it does not seem to make a difference.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ingsms | last post by:
Hi, Does anyone have any suggestions on an approach to speed this up please? I need to check a given column in a given table to see whether there are any characters within any of the records...
5
by: Ada | last post by:
hello folks, just wanna get some feedback from someone here who has more experience. :-) i'm developing a small app that require searching for the highest index within a directory. i was...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
1
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file,...
1
by: Tony | last post by:
I have been using TinyMCE as a WYSIWYG editor for getting content into a database and then exporting that data into an XML format to redender in flash using CDATA. The problem is that I didn't...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
5
by: praveenhathwar | last post by:
Hi, Im new to this Forum. Im facing a problem from long time. I have a text box. If user types a character, I should display the itemname (records/data) into Flexgrid starting from those characters....
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
4
by: amollokhande1 | last post by:
Hi, I am fetching the data from the database and assigning it to the textarea. Before that Xml is loaded with data and then stylesheet gets applied to the xml to generate the html output with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.