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?