Solved

Sort nvarchar in SQL Server 2005

Posted on 2009-07-14
2
296 Views
Last Modified: 2012-05-07
in SQL Server 2005, how do we sort this nvarchar field

SO204750000000011
SO50340000000001
SO53000000000002
SO68190000000003

so it will become

SO50340000000001
SO53000000000002
SO68190000000003
SO204750000000011
0
Comment
Question by:doramail05
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24855646
ORDER BY CAST( REPLACE (urColumn, 'SO', '') as BIGINT )
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24855779
order by cast(right(fieldname, 3) as int) asc
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-SQL: Episode III - Revenge of The Dude 24 53
SQL Server Designer 19 44
Simple SQL query from two tables 13 54
Flattening heirachies 3 31
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question