简体   繁体   中英

Arrange data in ascending order in SQL SERVER 2008

I have a table in which one of the column stores name. The names are stored as John,jimmy,Steve,smith,Shaun.

I would like to display it as

jimmy
John
Shaun
smith
Steve

The name are displayed in alphabetical order.

Which query should I use in SQL SERVER 2008. I have tried using collate nocase which gave me an error. My database collation is Latin1_General_CI_AS

Simple

SELECT * FROM table ORDER BY [name] ASC

Doesn't work for you ?

Use ORDER BY CLAUSE , It will resolve your problem

 select name from tablename order by name COLLATE NOCASE.

OR

select name from tablename order by Lower(name)

With collate you specify how the column values are treated in operations, if eg equality check is case sensitive or case insensitive. This has nothing to do with ordering your values using a select statement.

The ordering is simply forced by an order by like already said.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM