473,382 Members | 1,165 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,382 software developers and data experts.

Tricky Case Sensitive Query on SQL7

I have a SQL7 database that was installed as case-insensitive.
/* Sort Order = 52, Case-insensitive dictionary sort order. */

This database contains a table that has a varchar column which contains
data such as:

'JUDICIARY; EDUCATION; Subcommittee on Justice and Judiciary'
'Subcommittee on Justice and Judiciary; TRANSPORTATION'
'Subcommittee on Cities; JUDICIARY; TRANSPORTATION'

I want to write a SELECT statement that gives me only those rows (1st
and 3rd) that have JUDICIARY (not Judiciary) in the varchar column.

This is SQL7 so I can't use COLLATE.

I tried

SELECT mycol
FROM mytable
WHERE mycol LIKE '%JUDICIARY%'
AND CAST(SUBSTRING(mycol ,PATINDEX('%JUDICIARY%',mycol
),LEN('JUDICIARY')) AS VARBINARY) = CAST('JUDICIARY' AS VARBINARY)

But this leaves out the row with JUDICIARY and Judiciary in it (only
returns 3rd row).

Any suggestions?

Jul 23 '05 #1
3 2955
If it is case SENSITIVE I would think a simple like '%JUDICIARY%'
would suffice.
Not having access to a case - sensitive database, I can't test.
kevin ruggles
"Jeff" <je**********@lrc.state.ky.us> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a SQL7 database that was installed as case-insensitive.
/* Sort Order = 52, Case-insensitive dictionary sort order. */

This database contains a table that has a varchar column which contains
data such as:

'JUDICIARY; EDUCATION; Subcommittee on Justice and Judiciary'
'Subcommittee on Justice and Judiciary; TRANSPORTATION'
'Subcommittee on Cities; JUDICIARY; TRANSPORTATION'

I want to write a SELECT statement that gives me only those rows (1st
and 3rd) that have JUDICIARY (not Judiciary) in the varchar column.

This is SQL7 so I can't use COLLATE.

I tried

SELECT mycol
FROM mytable
WHERE mycol LIKE '%JUDICIARY%'
AND CAST(SUBSTRING(mycol ,PATINDEX('%JUDICIARY%',mycol
),LEN('JUDICIARY')) AS VARBINARY) = CAST('JUDICIARY' AS VARBINARY)

But this leaves out the row with JUDICIARY and Judiciary in it (only
returns 3rd row).

Any suggestions?

Jul 23 '05 #2
I changed my display name.
kevin
"Data" <no**********@anywhereButHere.org> wrote in message
news:cp**********@gnus01.u.washington.edu...
If it is case SENSITIVE I would think a simple like '%JUDICIARY%'
would suffice.
Not having access to a case - sensitive database, I can't test.
kevin ruggles
"Jeff" <je**********@lrc.state.ky.us> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a SQL7 database that was installed as case-insensitive.
/* Sort Order = 52, Case-insensitive dictionary sort order. */

This database contains a table that has a varchar column which contains
data such as:

'JUDICIARY; EDUCATION; Subcommittee on Justice and Judiciary'
'Subcommittee on Justice and Judiciary; TRANSPORTATION'
'Subcommittee on Cities; JUDICIARY; TRANSPORTATION'

I want to write a SELECT statement that gives me only those rows (1st
and 3rd) that have JUDICIARY (not Judiciary) in the varchar column.

This is SQL7 so I can't use COLLATE.

I tried

SELECT mycol
FROM mytable
WHERE mycol LIKE '%JUDICIARY%'
AND CAST(SUBSTRING(mycol ,PATINDEX('%JUDICIARY%',mycol
),LEN('JUDICIARY')) AS VARBINARY) = CAST('JUDICIARY' AS VARBINARY)

But this leaves out the row with JUDICIARY and Judiciary in it (only
returns 3rd row).

Any suggestions?


Jul 23 '05 #3
[posted and mailed, please reply in news]

Jeff (je**********@lrc.state.ky.us) writes:
I have a SQL7 database that was installed as case-insensitive.
/* Sort Order = 52, Case-insensitive dictionary sort order. */

This database contains a table that has a varchar column which contains
data such as:

'JUDICIARY; EDUCATION; Subcommittee on Justice and Judiciary'
'Subcommittee on Justice and Judiciary; TRANSPORTATION'
'Subcommittee on Cities; JUDICIARY; TRANSPORTATION'

I want to write a SELECT statement that gives me only those rows (1st
and 3rd) that have JUDICIARY (not Judiciary) in the varchar column.


This appears to work:

CREATE TABLE jeff (a varchar(200) NOT NULL)
go
INSERT jeff (a) VALUES
('JUDICIARY; EDUCATION; Subcommittee on Justice and Judiciary')
INSERT jeff (a) VALUES
('Subcommittee on Justice and Judiciary; TRANSPORTATION')
INSERT jeff (a) VALUES
('Subcommittee on Cities; JUDICIARY; TRANSPORTATION')
go
declare @b varbinary(200)
select @b = convert(varbinary(200), 'JUDICIARY')
select * from jeff
where charindex(@b, convert(varbinary(200), a)) > 0
go
drop table jeff

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

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

Similar topics

32
by: Elliot Temple | last post by:
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline comments? Would adding them cause a problem of some...
9
by: Jeff | last post by:
i have this on my signup page Set rs = Conn.Execute("SELECT * from rounds") DO WHILE NOT rs.EOF IF request.form("username") = rs.fields.item("username").value THEN ...
1
by: JP | last post by:
Hi, I have yet to find an answer for this: I want to do a case-sensitive query using "like" on a table in sql 7. Currently, "like" performs case-insensitive query. I understand that you can...
2
by: J. Muenchbourg | last post by:
I'm doing a few tests with simple .net scripts, and I noticed that I display the following error message at ErrMessage.Text if I don't enter "BLUE" in capital letters into my input textbox: ...
4
by: xAvailx | last post by:
Hello: I didn't find any documentation that notes save point names are case sensitive, but I guess they are... Stored Proc to reproduce: /* START CODE SNIPPET */ If Exists (Select * From...
38
by: Bart | last post by:
Why is C case sensitive? I know it's a bit late to change it now but there would seem to be far more advantages in ignoring letter case in source code. In real life such a situation would be...
2
by: Lucky | last post by:
Hi guys, I'm having problem with case sensitive collation of SQL Database. one my client is having case sensitive database. While developing the Data Layer i didn't consider this scenario. the...
6
by: Derik | last post by:
Okay, I THINK this is a PHP question... I've been mucking with PHP for awhile now, but just recently I've been poking at some ajax stuff, and I ran into something confusing; my Queries were...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.