Reputation: 1
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
Upvotes: 0
Views: 286
Reputation: 15387
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)
Upvotes: 0
Reputation: 9131
With collate
you specify how the column values are treated in operations, if e.g. 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.
Upvotes: 0
Reputation: 45285
Simple
SELECT * FROM table ORDER BY [name] ASC
Doesn't work for you ?
Upvotes: 1