Solved

Sort nvarchar in SQL Server 2005

Posted on 2009-07-14
2
286 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now