Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:18:31+00:00 2026-06-14T04:18:31+00:00

there is a table’s fields on MSSQL Serrver 2005 as VARCHAR. It contains alphanumeric

  • 0

there is a table’s fields on MSSQL Serrver 2005 as VARCHAR. It contains alphanumeric values like “A,B,C,D … 1,2,3,…,10,11,12” etc.

When i use below codes;

....   
ORDER BY TableFiledName

Ordering result is as follow 11,12,1,2,3 etc.

When i use codes as below,

....   
 ORDER BY
    CASE WHEN ISNUMERIC(TableFiledName) = 0 THEN CAST(TableFiledNameAS INT) ELSE TableFiledName END

I get error message as below;

Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar
to float.

How can get like this ordering result: 1,2,3,4,5,6,7,8,9,10,11,12 etc..

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:18:33+00:00Added an answer on June 14, 2026 at 4:18 am

    ISNUMERIC returns 1 when the field is numeric.

    So your first problem is that it should be …

       CASE WHEN ISNUMERIC(TableFiledName) = 1 THEN 
    

    But this alone won’t work.

    You need to prefix the values with zeroes and take the rightmost

     order by 
          case when ISNUMERIC(FieldName) =1 
          then right('000000000'+FieldName, 5)
          else FieldName 
          end
    

    Using 5 allows for numbers up to 99999 – if your numbers are higher, increase that number.

    This will put the numbers before the letters. If you want the letters before the numbers, then you can add an isnumeric to the sort order – ie:

     order by
          isnumeric(FieldName),
          case...
    

    This won’t cope with decimals, but you haven’t mentioned them

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a Table there is a single attribute(column).it contains numbers.Some are repeated(2 or 3
There is a table: create table table1 ( id integer primary key, user_id varchar(36),
Let's say I have two tables with several fields and in every table there
In a table there are like 113 columns. and there are two default records
Is there any table which contains IATA (International Air Transport Association airport code)codes for
I created a table Place in mysql. In this table there are three fields.
It's a question I got this afternoon: There a table contains ID, Name, and
is there any table-like widget or control which content can be edited in the
I have a table in an access database named CombinedBomItems. It contains the fields:
Is there a table i can query all of Oracle Reserved Words? Example, i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.