Descending the Alphanumeric character in SQL Server 2008
HiWhile trying to descending the Alphanumeric characters (based on date in middle of the string) it shown wrongly. Below is the value and query. Actually the PONumber column were in Nvarchar in sql.
Query:
select * from PurchaseOrders order by
CONVERT(NVARCHAR, PONumber, 118)+' '+CONVERT(NVARCHAR, PONumber, 118) desc
Answer yield as:
PO-12-27-2016-2016FMD073
PO-12-22-2016-2016FMD072
PO-12-16-2016-2016FMD071
PO-12-14-2016-2016FMD070
PO-12-06-2016-2016FMD069
PO-11-29-2016-2016FMD068
PO-02-16-2017-2017FMD012
PO-01-27-2017-2017FMD008
PO-01-13-2017-2017FMD005
PO-01-05-2017-2017FMD002
Actual required answer is:
PO-11-29-2016-2016FMD068
PO-12-06-2016-2016FMD069
PO-12-14-2016-2016FMD070
PO-12-16-2016-2016FMD071
PO-12-22-2016-2016FMD072
PO-12-27-2016-2016FMD073
PO-01-05-2017-2017FMD002
PO-01-13-2017-2017FMD005
PO-01-27-2017-2017FMD008
PO-02-16-2017-2017FMD012
How can i process this..