Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server case sensitive query with wildcards

Status
Not open for further replies.

adam0101

Programmer
Jun 25, 2002
1,952
US
I need to know how to create a query that is case sensitive and can include wildcards. I found this code:
Code:
Select * From table Where CAST(@searchTerm AS varbinary(12))=CAST(dbField AS varbinary(12))

But it doesn't allow wildcards. I modified it to this:
Code:
Select * From table Where CAST (@searchTerm AS varbinary(12)) = CAST (SubString(dbField,PatIndex('%'+@searchTerm+'%',dbField),Len(@searchTerm)) AS varbinary(12))

But PatIndex() is case in-sensitive so it only compares the first instance of the (in-sensitive) search term. In other words, if I were searching for 'AAA' it would match 'xxxAAAaaaxxx' but not 'xxxaaaAAAxxx'.

Is there another way? I'm using SQL Server 7.0 and changing the whole server to be Case Sensitive is out of the question. HELP!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top