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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you sort records?

Status
Not open for further replies.

bongmarley

Programmer
Oct 21, 2002
74
CA
In SQL Server how do you sort records. If I click on my id field and highlight the whole field how do I sort it either descending or ascending. The button to do this is always greyed out like it is unactive.
 
My sort buttons are disabled also and I haven't found a way to enable them. However, I get around this by manually changing the SQL that creates the rowset. Until someone provides an answer of how to enable these buttons, you might try the following:

While viewing your table rows:

1)Click the SQL icon(in my list, about 6 icons before the sort buttons)

2)The SQL is shown such as follows:
SELECT *
FROM CORP

3)Add the following specifying the name of the column you want to sort by and whether you want it to sort ascending(ASC) or descending(DESC). Ascending is default and doesn't have to be specified

SELECT *
FROM CORP
ORDER BY ID DESC

4)Click the ! icon to execute the query and see the rows sorted in the order specified.

Hope this helps until someone can provide the exact answer you're looking for.

 
The sort buttons in Enterprise Manager don't work in the same way as they do in Access. They can be used to add Order By columns to a query.

From Enterpise Manager, open a table as a query. Note that the table columns are listed in the diagram pane. If you click on one of the column names, the sort buttons will be enabled. Click on one of the buttons (Asc or Desc) and the query designer adds an order by clause to the query using the column name selected. You can see the order by clause in the SQL pane. Other columns can be added in the same way.

Currently, Enterprise Manager is not as sophisticated as Access. It doesn't have all the same GUI features.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top