DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Dan Zettle Guest

    Is there a 'StrComp' T-SQL equivalent


    I am trying to compare two strings within a stored procedure and the comparison
    needs to be binary. I noticed that string comparisons are text based:

    'test' = 'TEST'

    My comparison must be binary so that the two result in not being equal.
    Within VB, I would normally use:

    StrComp('test','TEST',vbBinaryCompare)

    but I cannot find any equivalent function within T-SQL. How can I do a binary
    comparison on two strings? Thanks.

  2. #2
    Kristin Piskulic Guest

    Re: Is there a 'StrComp' T-SQL equivalent


    I know this is an ugly solution -- but it seems to give you what you're looking
    for:

    IF Convert(binary,'TEST') = Convert(binary,'TEST')
    PRINT 'Match'
    ELSE
    PRINT 'No Match'

    K. Piskulic


    "Dan Zettle" <dan.zettle@shoptok.com> wrote:
    >
    >I am trying to compare two strings within a stored procedure and the comparison
    >needs to be binary. I noticed that string comparisons are text based:
    >
    >'test' = 'TEST'
    >
    >My comparison must be binary so that the two result in not being equal.


    >Within VB, I would normally use:
    >
    >StrComp('test','TEST',vbBinaryCompare)
    >
    >but I cannot find any equivalent function within T-SQL. How can I do a

    binary
    >comparison on two strings? Thanks.



  3. #3
    Chase Saunders Guest

    Re: Is there a 'StrComp' T-SQL equivalent

    I seem to recall this being an option for the entire server...

    Another technique is to conver the strings to uppercase, although it looks
    like the above suggestion beats that.

    Chase



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links