Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sort nvarchar in SQL Server 2005

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nested Case statement 4 37
Download ms sql express. 2 25
SQL create line numbers for data sampling 11 27
Current Month Filter in Visual Studio 10 22
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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.
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.

839 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