The meaning of SQL Server four matching characters

Source: Internet
Author: User
Tags range

The meaning of four kinds of matching characters

% represents 0 or more arbitrary characters

Represents an arbitrary character

[] Any single character within the specified range

[^] Any single character not in the specified range

Strings with matching characters must be enclosed in quotation marks, such as the following example:

Like ' br% ' returns any string that starts with "BR".

Like ' br% ' returns any character that starts with "Br".

Like '%een ' returns any string that ends with "een".

Like '%en% ' returns any string containing "en".

Like ' en ' returns a string of three characters ending with "en".

Like ' [ck]% ' returns any string that starts with "C" or "K".

Like ' [S-v]lng ' returns a string of four characters, ending with ' ing ', which starts from S to V

Like ' m[^c]% ' returns any string that starts with "M" and the second character is not "C". Attention:

Using the LIKE operator usually causes SQL Server to not use the index associated with the given table. It tells SQL Server to compare the specified string and find any content that matches the provided matching character. Because of this, it is not recommended to use this type of search or comparison on large tables, or at least to remind users that it is important for the system to find the waiting time required to meet the criteria for searching data rows.

Related Article

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.