Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nvarchar sorting incorrectly 1

Status
Not open for further replies.

jballum

MIS
Jul 10, 2000
161
CA
If someone has 2 minutes could you please run the following scripts that perform the following:

a) create a table named 'eraseme'
b) insert some records into table 'eraseme'
c) run 2 select queries against table 'eraseme'
d) drop table 'eraseme'

Afterwards compare the results of the two select queries. If they are exactly the same then you could you think of why my results are not. I am actually getting an incorrect order when I sort using the nvarchar field but the correct order when I convert this field to varchar during the select.

If you are getting different results then is this a SQL Server bug?

Thanks a lot,
JB

CREATE TABLE dbo.[eraseme] (
[F1] [nvarchar] (10) NOT NULL
) ON [PRIMARY]
GO

INSERT INTO dbo.[eraseme]
(F1)
VALUES
("x-a")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("xmas")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("xmas")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("x'mas")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("x-mas")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("xmas A")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("X'mas B")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("x-mas B")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("xmas BB")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("x'mas CC")
INSERT INTO dbo.[eraseme]
(F1)
VALUES
("X-mas CC")
GO

select
f1
from eraseme
order by f1

select
f1
from eraseme
order by convert(varchar, f1)
GO

drop table dbo.[eraseme]
GO


 
Yep, different order for me too. Don't know why
I'm using SQL 7 SP 2

 
Colin,

Thanks for running the scripts and checking the outcome for me.

I am running SQL 7 SP 2 as well.

I am totally lost as to what is causing this. Does anyone know what steps that can be taken to check/report on bugs?

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top