Why do I get invalid rows returned containing hyphens when my where clause doesn't specify them?
Neil Pike
November 1, 1999
1 Min Read
A. This only happens with Unicode columns because Unicode sorts/compares are based on the Windows standard which effectively ignores the hyphen character.
as an example
create table t (cocode nvarchar(6))
go
insert into t values ('AXB')
insert into t values ('AXC')
insert into t values ('A-Y')
go
select * from t where
(cocode > 'A-X') AND (cocode < 'A-Z')
produces:
cocode
------
AXB
AXC
A-Y
(3 row(s) affected)
If the nvarchar(6) is changed to varchar(6) then the expected result set is produced (only row A-Y appears).
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like