Page 1 of 1

Sql-Server: How to elimate "-"?

Posted: Tue 11 Jan 2011 15:54
by invent
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

Posted: Thu 13 Jan 2011 08:03
by AndreyZ
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