Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Sort order in SQL 2005?

 
   Database Help (Home) -> Programming RSS
Next:  Crosstab query in sql server 2000  
Author Message
nomad

External


Since: Apr 12, 2007
Posts: 4



(Msg. 1) Posted: Wed Feb 07, 2007 6:48 am
Post subject: Sort order in SQL 2005?
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hi,

When sorting a numeric field in SQL 2005, I am finding that it is
sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
1002, 2, 20, 2000, 2002. Is there a reason for this?

Appreciate the help.

Damon

 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
nomad

External


Since: Apr 12, 2007
Posts: 4



(Msg. 2) Posted: Wed Feb 07, 2007 7:34 am
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 7 Feb, 15:24, "Aaron Bertrand [SQL Server MVP]"
wrote:
> Uri, I think you misunderstood the question. It sounds like nomad IS using
> an ORDER BY clause.
>
> "Uri Dimant" wrote in message
>
>
>
> > nomad
> > This is why you always need to specify ORDER BY clause
>
> > "nomad" wrote in message
> >
> >> Hi,
>
> >> When sorting a numeric field in SQL 2005, I am finding that it is
> >> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
> >> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>
> >> Appreciate the help.
>
> >> Damon

Yes, I am using an Order By clause on a numeric field, but is not
ordering it correctly. Like I said above 1, 10, 2, 20 etc it should be
1, 2, 10, 20 etc. Anyone have any contructive opinions on why this
may be happening?

Appreciate the help

 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Mike C#

External


Since: Jan 12, 2008
Posts: 483



(Msg. 3) Posted: Wed Feb 07, 2007 10:04 am
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Because it's a VARCHAR or NVARCHAR column???

"nomad" wrote in message

> Hi,
>
> When sorting a numeric field in SQL 2005, I am finding that it is
> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>
> Appreciate the help.
>
> Damon
>
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Mike C#

External


Since: Jan 12, 2008
Posts: 483



(Msg. 4) Posted: Wed Feb 07, 2007 10:41 am
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"nomad" wrote in message

> Yes, I am using an Order By clause on a numeric field, but is not
> ordering it correctly. Like I said above 1, 10, 2, 20 etc it should be
> 1, 2, 10, 20 etc. Anyone have any contructive opinions on why this
> may be happening?
>
> Appreciate the help

Post your DDL for the table and the query you are using with the ORDER BY
clause, so we can reproduce it. Like I said, that's the *exact* result one
would expect if one were ordering by a VARCHAR, CHAR, NVARCHAR, or NCHAR
column.
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Aaron Bertrand [SQL Serve

External


Since: Jan 10, 2008
Posts: 2166



(Msg. 5) Posted: Wed Feb 07, 2007 10:45 am
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> Yes, I am using an Order By clause on a numeric field, but is not
> ordering it correctly. Like I said above 1, 10, 2, 20 etc it should be
> 1, 2, 10, 20 etc. Anyone have any contructive opinions on why this
> may be happening?

Mike already asked if you are sure this column is numeric (implying that
maybe it is character of some variation).
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Mike C#

External


Since: Jan 12, 2008
Posts: 483



(Msg. 6) Posted: Wed Feb 07, 2007 10:46 am
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Aaron Bertrand [SQL Server MVP]" wrote in message

>> Yes, I am using an Order By clause on a numeric field, but is not
>> ordering it correctly. Like I said above 1, 10, 2, 20 etc it should be
>> 1, 2, 10, 20 etc. Anyone have any contructive opinions on why this
>> may be happening?
>
> Mike already asked if you are sure this column is numeric (implying that
> maybe it is character of some variation).

I'll bet you a shiny new nickel it's either a non-numeric column or he is
casting the column to a non-numeric type in his order by
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Uri Dimant

External


Since: Aug 24, 2003
Posts: 1744



(Msg. 7) Posted: Wed Feb 07, 2007 5:11 pm
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

nomad
This is why you always need to specify ORDER BY clause




"nomad" wrote in message

> Hi,
>
> When sorting a numeric field in SQL 2005, I am finding that it is
> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>
> Appreciate the help.
>
> Damon
>
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Aaron Bertrand [SQL Serve

External


Since: Jan 10, 2008
Posts: 2166



(Msg. 8) Posted: Wed Feb 07, 2007 5:11 pm
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Uri, I think you misunderstood the question. It sounds like nomad IS using
an ORDER BY clause.





"Uri Dimant" wrote in message

> nomad
> This is why you always need to specify ORDER BY clause
>
>
>
>
> "nomad" wrote in message
>
>> Hi,
>>
>> When sorting a numeric field in SQL 2005, I am finding that it is
>> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
>> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>>
>> Appreciate the help.
>>
>> Damon
>>
>
>
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Uri Dimant

External


Since: Aug 24, 2003
Posts: 1744



(Msg. 9) Posted: Wed Feb 07, 2007 5:27 pm
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Well ,I could be wrong but two things like a "numeric filed " and "sorting"
did not think to interpret as ORDER BY clause





"Aaron Bertrand [SQL Server MVP]" wrote in message

> Uri, I think you misunderstood the question. It sounds like nomad IS
> using an ORDER BY clause.
>
>
>
>
>
> "Uri Dimant" wrote in message
>
>> nomad
>> This is why you always need to specify ORDER BY clause
>>
>>
>>
>>
>> "nomad" wrote in message
>>
>>> Hi,
>>>
>>> When sorting a numeric field in SQL 2005, I am finding that it is
>>> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
>>> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>>>
>>> Appreciate the help.
>>>
>>> Damon
>>>
>>
>>
>
>
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Uri Dimant

External


Since: Aug 24, 2003
Posts: 1744



(Msg. 10) Posted: Wed Feb 07, 2007 5:39 pm
Post subject: Re: Sort order in SQL 2005? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

nomad

If you want us to reproduce the behaviour ,please post DDL+ samle data






"nomad" wrote in message

> On 7 Feb, 15:24, "Aaron Bertrand [SQL Server MVP]"
> wrote:
>> Uri, I think you misunderstood the question. It sounds like nomad IS
>> using
>> an ORDER BY clause.
>>
>> "Uri Dimant" wrote in message
>>
>>
>>
>> > nomad
>> > This is why you always need to specify ORDER BY clause
>>
>> > "nomad" wrote in message
>> >
>> >> Hi,
>>
>> >> When sorting a numeric field in SQL 2005, I am finding that it is
>> >> sorting it differently than it was in 2000. i.e. 1, 10, 1000, 1001,
>> >> 1002, 2, 20, 2000, 2002. Is there a reason for this?
>>
>> >> Appreciate the help.
>>
>> >> Damon
>
> Yes, I am using an Order By clause on a numeric field, but is not
> ordering it correctly. Like I said above 1, 10, 2, 20 etc it should be
> 1, 2, 10, 20 etc. Anyone have any contructive opinions on why this
> may be happening?
>
> Appreciate the help
>
 >> Stay informed about: Sort order in SQL 2005? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Sort order in SQL 2005 - In a 2005 database table function that has SELECT TOP 100 Percent .... ORDER BY TextField This displays it in the primary key (numeric field) order and not the specified. Is there a setting change that is required to make the function return the order as...

Help with distinct + sort order - Hi I've the following set of un-normalised records. SortID Customer 1 ccc 2 ccc 3 aaa 4 aaa 5 bbb 6 bbb I need to perform a select which will return distinct Customer name while ..

Sort order and view - HI all, Using SQL 2005, I create a simple view Select * from employee order by name But when I select the view with select * from employeeview the sort order is not adheered to. I have to specificcally issue a order by on the view Can someone explain...

Order by [alias] in 2005 issue - So this 'order by' works in SQL2000, but will error in 2005 - select top 1 a.forderID [orderId] from MyTable a order by a.orderid SQL2005 eRR: Msg 207, Level 16, State 1, Line 2 Invalid column name 'orderid'. How to work around? Is there a server...

"order by" in SQL 2005 vs. SQL 2000 or other issue? - I am trying to find any issue why the data is not coming out as it is intended. I converted table and stored procedure from SQL 2000 to SQL 2005. However, on several reports, data is not listed as it is intended by "order by" clause. I guess o...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]