Re: Sort database alphabetically

From: Gert-Jan Strik (sorry_at_toomuchspamalready.nl)
Date: 11/26/04


Date: Fri, 26 Nov 2004 19:57:20 +0100

Jeff,

The only way to guarantee sorted output is by specifying an ORDER BY
clause.
What I am saying is that you cannot sort the database, and even if you
could, it would be useless, because the order of the resultset can only
be specified by the query.

So all you need to do is add "ORDER BY Name" to your existing query.

Hope this helps,
Gert-Jan

Jeff wrote:
>
> Yes, what I'd like to do is have the table in a known order so that as a web
> based query is performed on the database the results are already in the
> order they should be displayed (alphabetically based on a column of
> surnames). Currently the database is not sorted in the order I'd like. I
> know almost nothing about enterprise manager and SQL so I was wondering how
> to accomplish this task.
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
> news:42543446-C493-45A1-8513-9967D1229A24@microsoft.com...
> > I assume you mean you want to sort a specific table rather than a
> database.
> > What you should do is sort the result when you *query* the table. In
> > Enterprise Manager right -click on the table name and choose Open Table >
> > Query. In the Query Designer screen use the Sort Order column to specify
> how
> > you want the result sorted.
> >
> > A database table is logically unsorted. Although you can create indexes
> > which hold data in a known order for the purposes of query optimization,
> this
> > is NOT the same as sorting the actual result of a query. What I understand
> > you to mean by your question is that you want to see the result sorted on
> > screen. To do this you always need to specify the sort order in a query,
> for
> > example using EM's Query Designer or using an ORDER BY clause in
> Transact-SQL.
> >
> > Hope this helps.
> >
> > --
> > David Portas
> > SQL Server MVP
> > --
> >
> >
> > "Jeff" wrote:
> >
> > > I'm new to sql server and have a large database with four columns that I
> > > would like to sort alphabetically in ascending order based on a column
> of
> > > names (column is called Name). Could someone advise me how I can use
> > > enterprise manager to sort the database?
> > > Jeff
> > >
> > >
> > >



Relevant Pages

  • Re: sorting
    ... When I sort the data using SQL, ... But this is just the sorting. ... If it were me I would query the database and bring back the ...
    (microsoft.public.vb.enterprise)
  • Ordering on Hierarchical Dot Notation
    ... I have a SQL database (MySql) containing a table with a key column which ... The problem is that this column is proving very difficult to sort naturally ... users still want to query the database using the natural representation. ...
    (comp.lang.java.databases)
  • Ordering on Hierarchical Dot Notation
    ... I have a SQL database (MySql) containing a table with a key column which ... The problem is that this column is proving very difficult to sort naturally ... users still want to query the database using the natural representation. ...
    (comp.lang.java.programmer)
  • Re: Using a Select Query to build a MDB table from a Fox table
    ... MS Access has a 'make-table' query with IN clause you can specify ... As you said the IN <database> clause is specific to Access SQL. ...
    (microsoft.public.fox.helpwanted)
  • Re: default select order
    ... database version is 10.2.0.1.0. ... Now I'm wondering why 10g2 works like this (every time I query)? ... Ei kaytossa (refers to E) ... If you do not specify an order by clause then the order the results come ...
    (comp.databases.oracle.server)

Quantcast