Link to home
Start Free TrialLog in
Avatar of stephen_aus
stephen_aus

asked on

MS SQL Server 2008 R2 - like 'S%' returns no rows but like 'Se%' does

I have a MS SQL 2008 R2 production database that does not like 'S%'

the statements:
select * from TLMS.ELEMENT where ELEMENT_ID like 'S%' ;
select * from TLMS.ELEMENT where ELEMENT_ID like 'S_' ;
select * from TLMS.ELEMENT where ELEMENT_ID like '[S]%' ;

all return zero rows.

Whereas the statement (for example)

select * from TLMS.ELEMENT where ELEMENT_ID like 'Se%' ;

returns two rows.

All other 'non-S-as-first-character' matches are OK and other databases on the same engine are OK with 'S%'.

Any ideas?
Avatar of chaau
chaau
Flag of Australia image

Is ELEMENT_ID varchar, nvarchar, or something else?
Avatar of stephen_aus
stephen_aus

ASKER

Thanks for your reply
varchar(12) - I have also just noticed that the Collation type that we have used on this database can cause unexpected results with pattern matching with wildcards.

The collation we are using is:
Latin1_General_100_CS_AI_KS

I think the solution is the latest service pack for MS SQL Server 2008 R2 or to change the collation type to something like: SQL_Latin1_General_CP1_CI_AS
Collation might be a problem.
You know, you can change the collation for one of the tables to test, before applying it to the whole database
The problem is that this is a production database with many PK, FK constraints - the change will be difficult. I will probably go with the latest service pack for SQL Server - thanks for you replies.
ASKER CERTIFIED SOLUTION
Avatar of Tony303
Tony303
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial