Sql-Server: How to elimate "-"?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Sql-Server: How to elimate "-"?

Post by invent » Tue 11 Jan 2011 15:54

Hello,

we are using UniDAC with Interbase 2009, Oracle 8.0.5 and MS SQL-Server 2008 RC2. Delphi 7 and UniDAC 3.50.0.13.

I have a Table "ARTIKEL", with the string-fields "ARTIKELID", "SUCHBEGRIFF" and some more.

The Query

select artikelid, suchbegriff
from artikel
where suchbegriff >= 'LEXM'
and suchbegriff <= 'LEXN'

works fine with Interbase and Oracle. But with Sql-Server i got the result:

16568 LEXMARK
15185 LEXMARK 2390 PLUS
15186 LEXMARK 2390 PLUS
16018 LEX-MARK 2391 PLUS
27306 LEXMARK C500N 64MB 31PPM A4 COLOR USB

Why is "LEX-MARK 2391 PLUS" in the result of this Query???? And how can I avoid this?

Thanks in advance for this answer.

Kind regards,
Gerd Brinkmann
invent GmbH

AndreyZ

Post by AndreyZ » Thu 13 Jan 2011 08:03

Hello,

This is a specificity of SQL Server work and not UniDAC. You can check it using Microsoft SQL Server Management Studio. You can use one of the following solutions:

Code: Select all

select artikelid, suchbegriff
from artikel 
where cast(suchbegriff as varbinary) >= cast('LEXM' as varbinary)
and cast(suchbegriff as varbinary) = 'LEXM' collate Latin1_General_BIN
and suchbegriff <= 'LEXN' collate Latin1_General_BIN

Post Reply