Avatar of FrankLu
FrankLu
 asked on

SQL2008R2 ORDER BYnot working

Hi All,
I installed over the weekend SQL 2008R2 Express. I imported a table tblabbreviations (ID, Abbreviation (nvarchar(10), Description Nvarchar(50).
Afterwards I added some records and created a new Query
SELECT * from dbo.tblAbbreviations
ORDER BY Abbreviation
Problem:In the rsult Nothing is sorted.
If I enter in the blank table new records via (Access Frontend)then ORDER By works fine for these records , but not when some others were imported.

I looked already on the internet and some sources say to run SQL Server Compatibility Level SQL Server 2000(80). But this did not work too.

Appreciatate any help.

Thanks in advance
Best regrads
Frank
 
Microsoft SQL Server 2008Microsoft Access

Avatar of undefined
Last Comment
Guy Hengel [angelIII / a3]

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dqmq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
FrankLu

ASKER
Hi Dqmq, thanks for your qick reply. I'm quite new to SQL Server. But I got an error on the fact using trim. How do you want me to implement your comment ?
Thanks in advance
Frank
FrankLu

ASKER
Hi DQMQ,

Indeed there is a blank space in some records which I could not see at first sight.
I adapted with trim and it works fine.
Thanks for your support
Best regards
Frank
FrankLu

ASKER
I could not see that ther was a blank space as first character. Thanks
Frank
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Guy Hengel [angelIII / a3]

it would be rtrim() and/or ltrim() ... sql server does not have trim() ...

and you need to clarify with data samples of what you see "wrong results".
likely, your field is varchar, containing numerical data, and it sorts by design on varchar data, and not the "numerical data" ...