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

  • Home
  • SEARCH
  • 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 809081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:40:09+00:00 2026-05-15T00:40:09+00:00

I am looking for some SQL varchar comparison function like C# string.compare (we can

  • 0

I am looking for some SQL varchar comparison function like C# string.compare (we can ignore case for now, should return zero when the character expression are same and a non zero expression when they are different)

Basically I have some alphanumeric column in one table which needs to be verified in another table.

I cannot do select A.col1 – B.col1 from (query) as “-” operator cannot be applied on character expressions

I cannot cast my expression as int (and then do a difference/subtraction) as it fails

select cast ('ASXT000R' as int)
Conversion failed when converting varchar 'ASXT000R'  to int 

Soundex would not do it as soundex is same for 2 similar strings

Difference would not do it as select difference('abc','ABC') = 4 (as per msdn, difference is the difference in the soundex of 2 character expressions and difference =4 implies least different)

I can write a curson to do ascii comparison for each alphanumeric character in each row, but I was wondering if there is any other way of doing it ?

  • 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-05-15T00:40:10+00:00Added an answer on May 15, 2026 at 12:40 am

    we can ignore case for now, should return zero when the character expression are same and a non zero expression when they are different

    If that’s all you want, you can just use this:

    CASE WHEN 'a' = 'b' THEN 0 ELSE 1 END
    

    Note that this expression returns 1 when either of the arguments is NULL. This is probably not what you want. You can use the following to return NULL if either argument is NULL:

    CASE WHEN 'a' = 'b' THEN 0
         WHEN 'a' <> 'b' THEN 1
    END
    

    If you want negative and positive values depending on which compares ‘larger’, you could use this instead:

    CASE WHEN 'a' < 'b' THEN -1 
         WHEN 'a' = 'b' THEN 0
         WHEN 'a' > 'b' THEN 1
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some time now I'm looking for sample (relational) databases (.SQL) so I can
I'm looking at some SQL code which has a WHERE clause like this: WHERE
I'm currently looking for a good (free) tool to do some PL/SQL development on
I'm looking for a SQL-statement that sums up some specific values and sorts the
I am looking into using Lucene.NET after reading some bad reviews of SQL Server's
Looking for some help! I need to split a string at the last occurrence
I'm looking for some assistance converting the following sql query to LINQ to entities
Is there any way to check whether some string compatible with some MS SQL
I'm looking at some sql code with the following structure: set @var = (
I'm fiddling with a bit of c++/opencv. I was looking some of the samples

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.