Microsoft
Software
Hardware
Network
Question : varchar sort
orderid is a number
select * from trackingnumbers order by orderid desc
this command does not work
is this because orderid is a varchar
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[trackingnumbers](
[trackingnumberid] [int] IDENTITY(1,1) NOT NULL,
[date] [datetime] NOT NULL CONSTRAINT [DF_trackingnumbers_date] DEFAULT (getdate()),
[orderid] [varchar](50) NOT NULL,
[trackingnumber] [varchar](50) NULL,
[shipper] [varchar](10) NULL,
[cost] [decimal](10, 2) NULL,
[void] [varchar](20) NULL,
[name] [varchar](100) NULL,
[address] [varchar](100) NULL,
CONSTRAINT [PK__trackingnumbers__2B3F
6F97] PRIMARY KEY CLUSTERED
(
[trackingnumberid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
Answer : varchar sort
select * from trackingnumbers order by cast(orderid as bigint) desc
Random Solutions
Sagekey Question
ASP.Net validation controls not firing.
Query in SSRS take much longer than SSMS
MDaemon not collecting Domainpop mail
How to change start menu user default folder list in Windows 7
SQL Server backup and shrink
hstbar.xla can not be found After Excel 2007 was installed
Run macro in background without blocking Excel input / output
Where or between on row_number
Issue with performance of a SQL query