CHARINDEX (Transact-SQL)

Source: Internet
Author: User

CHARINDEX (Transact-SQL)

Syntax: CHARINDEX (expression 1, expression 2, start position)
Parameters:

Expression 1

Expression that contains the sequence-be found. ' xmlspace= ' preserve ' > a character expression that contains the sequence to find. Expressiontofind is limited to 8000 characters. ' xmlspace= ' preserve ' > expression 1 contains a maximum of 8,000 characters.

Expression 2 The character expression to search for. You can make the variable (expression 1 look in Expression 2) start_location

Integer or bigint expression at which the search starts. ' xmlspace= ' preserve ' > represents the integer or bigint expressions where the search starts. Start_location is isn't specified, is a negative number, or was 0, the search starts at the beginning of Expressiontosearch. ' xmlspace= ' Preserve > If start_location is not specified , the parameter is negative or 0, the search starts at the beginning of the Expressiontosearch. The default starts from the first bit of expression 2 to find

Extended:

CHARINDEX performs a comparison operation based on the collation entered. To compare with a specified collation, you can use COLLATE to apply an explicit collation to the input.

Case sensitive:

The following example performs a case-sensitive string ' Test ' Search in ' Das ist ein Test '.
SELECT CHARINDEX (' TEST ', ' Das ist ein TEST '
COLLATE latin1_general_cs_as);

Result is 0

SELECT CHARINDEX (' Test ', ' Das ist ein Test '
COLLATE latin1_general_cs_as);

Result is 13

Case insensitive

The following example performs a case-insensitive string ' Test ' Search in ' Das ist ein Test '.

SELECT CHARINDEX (' TEST ', ' Das ist ein TEST '
COLLATE latin1_general_ci_as)

Results: 13

CHARINDEX (Transact-SQL)

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.