?
Solved

SEARCH in TEXT field type in CASE SENSITIVE MS SQL SERVER 2000 Database

Posted on 2004-08-17
7
Medium Priority
?
992 Views
Last Modified: 2012-06-21
Hi friends,

I am having a problem with a simple select query which can be displayed as follows:

SELECT ID, NAME
FROM TABLE1
WHERE TABLE1.TEXTFIELD1 LIKE '%MySearchText%'

Since the Database is case sensitive I will have to use the UPPER function in the statement but the TEXT field type in the Database doesn't support this function.

Making database case insesitive in run time is not advisable since the database is shared in the network.

Is there anyone around who can help me?

0
Comment
Question by:juliusrai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 2

Expert Comment

by:tonyhowarth
ID: 11828604
Change the collation in the statement to an non case sensitive collation using the COLLATE function.

Tony
0
 

Author Comment

by:juliusrai
ID: 11829050
Thanks for participation tonyhowarth.

I got it how to do it.

the thing is if I CAST the field in VARCHAR within WHERE clause then I can use the UPPER function.

so the statement would look like this:

SELECT ID, NAME
FROM TABLE1
WHERE UPPER(CAST(TABLE1.TEXTFIELD1)) LIKE UPPER('%MySearchText%')

Thanks once again
0
 
LVL 2

Expert Comment

by:tonyhowarth
ID: 11829099
Yep, that's fine, but I would check the performance of the SQL with and without the UPPER.  Using a function in the where means that usage of indexes is adversely affected.

Tony
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:juliusrai
ID: 11829123
Please do it as I m not expert in SQL so I was also thinking about that.

Pleas let me know if you have better than this.

Also please give me the code using the COLLATE function if you can.

Thanks
0
 
LVL 2

Expert Comment

by:tonyhowarth
ID: 11829460
Doh....I may have mislead you slightly.  I went back to look at the code that I wrote to do this and it appears that the case sensitivity is handled on a Left Outer Join, as you can see below.

I am not sure you can do this on a WHERE clause.

SELECT Table1.*,Table2.* FROM Table1 LEFT OUTER JOIN Table2 ON Table1.Code = Table1.Code_Ref COLLATE SQL_Latin1_General_CP1_CI_AS


Sorry
Tony
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11866639
Closed, 125 points refunded.
Netminder
Site Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question