How do I distinguish case comparisons?

Source: Internet
Author: User
Tags sql server books
Comparison | case

Q: How do I write a program that can compare the case of a user's password in a case-insensitive instance of SQL Server 7.0?

A. If you have upgraded your system to SQL Server 2000, you can specify the collation of the data at the column level. (The SQL Server Books Online glossary defines collations as a set of rules that determine how to compare, arrange, and render data.) Character data is stored using collations, including locale, sorting criteria, and case sensitivity. )

However, you can use this technique only if you are upgrading to SQL Server 2000. Suppose the password value stored in the table is BamBi2000 (Note that "B" is uppercase and all other characters are lowercase):

DECLARE @user_password varchar (12)

IF CAST (@user_password as varbinary (12)) =
CAST (' BamBi2000 ' as varbinary (12))
PRINT ' Password match '
ELSE
PRINT ' Password mismatch '

-sql Server MVPs



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.