yes, I think my database does have the case-sensitively set on. I have a field with value "Catholic"
then if someone try to search for "catholic", nothing return
Main Topics
Browse All TopicsI need to do a non-case sensitive search on some ntext datatype in MS SQL. if it's varchar, char, etc., i usually do something like
WHERE UPPER(field1) LIKE 'myValue%'
however, when i try the same trick for these ntext datatype, it said I couldn't do it.
What should i do???? I am told by my boss that I must use ntext datatype due to user requirement.
Any suggestions would be helpful.
Thank you very much in advance!!
Gab
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Looking at your query, I note that you have a '%' only at the right side of the matching string. If this is the only place you will have the match wildcard, then for an NText field, you can use something like this (assumes a stored procedure for this example, without a wildcard):
WHERE Upper(SubString(Field1, 1, Len(@MyValue)) = Upper(@MyValue)
ntext column cannot be altered, it must be moved.
create table TableX(T ntext collate Latin1_General_CS_AS not null)
GO
alter table TableX add TX ntext collate Latin1_General_CI_AS not null default ''
--Put a modified BLOB moving script here for T->TX
See http://www.experts-exchang
alter table TableX drop column T
EXEC sp_rename 'TableX.[TX]', 'T', 'COLUMN'
gab_chong;
Rather than going through the exercise of changing tables, you may be able to get by with specifying the desired case-sensitivity at "compare-time" (note the COLLATE clause):
----- SQL SCRIPT -------
CREATE TABLE WithNTEXT(MyText ntext)
GO
INSERT INTO WithNTEXT VALUES('abcd')
INSERT INTO WithNTEXT VALUES('ABCD')
GO
--My server is set up case-insensitive. Therefore, I get both rows...
SELECT MyText FROM WithNTEXT WHERE MyText LIKE 'abcd%'
--Explicitely compare case-insensitive
SELECT MyText FROM WithNTEXT WHERE MyText LIKE 'abcd%' COLLATE Latin1_General_CI_AS
GO
--Explicitely compare case-sensitive
SELECT MyText FROM WithNTEXT WHERE MyText LIKE 'abcd%' COLLATE Latin1_General_CS_AS
GO
DROP TABLE WithNTEXT
GO
----- END SQL SCRIPT ----
HTH,
TroyK, MCSD
TroyK,
the problem with COLLATE is that it is assumed to be nondeterministic. If you create an index on a computed column, for ntext it can be UPPER(SUBSTRING()) only.
If the user wants to get results of LIKE 'xyz%' faster (up to 450 nchars), he must add the computed column anyway. Regardless of the case-sensitivity of the original column collation.
gab_chong:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
Business Accounts
Answer for Membership
by: kelfinkPosted on 2003-04-09 at 15:29:26ID: 8303316
is your database collating case-sensitively? By default, it doesn't.
In other words, you may not need that UPPER at all. I don't on my database.