Click here to Skip to main content
14,635,966 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
Good Evening ,

I have large number of data in sqlserver 2005 database , and

How to write a query in sqlserver 2005, to display the records alphabets wise.(a-z)

Thanx Experts.
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 2

You need to use the order by clause to order records in a query.
   
Comments
k@ran 17-Jul-12 6:07am
   
select * from employee to view record and
select * from employee order by emp_name asc|desc
Rate this:
Please Sign up or sign in to vote.

Solution 1

SELECT EMPLOYEE_NAME FROM EMPLOYEE_MASTER ORDER BY EMPLOYEE_NAME ASC
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Use of "ORDER BY" in t-sql sorts your records. You can read more about it here http://www.w3schools.com/sql/sql_orderby.asp[^]

SELECT * FROM [Table] ORDER BY [Column] ASC

Or the other way
SELECT * FROM [Table] ORDER BY [Column] DESC



If you have a large number of records you may consider indexing that column. http://www.sql-server-performance.com/2007/optimizing-indexes-general/[^]
   
Comments
Ranjith Reddy CSE 17-Jul-12 6:25am
   
SqlDataAdapter dad3 = new SqlDataAdapter("select ClearanceNumber, CodeFlightId, DateLastChange, DateValidFrom,"
+ "DateValidTo, ReservationNo, AircraftType, CityCode, Days from Flight order by CodeFlightId", con);

Please check this Query, I need Alphabet wise.

Please help, Please correct this Query
StianSandberg 17-Jul-12 6:37am
   
your query "SELECT ClearanceNumber, CodeFlightId, DateLastChange, DateValidFrom,DateValidTo, ReservationNo, AircraftType, CityCode, Days
FROM Flight
ORDER BY CodeFlightId"
will return all data ordered by CodeFlightId ascending. Are you downwoting two perfectly correct answers here?
Ranjith Reddy CSE 17-Jul-12 6:28am
   
This Query am using in dropdown list.....when i select sort by codeflightid it must display alphabet wise.

Please help , above is my query, am using that query in dropdownlist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100