-
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.
-
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.
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks