SQL Server substring () function

Source: Internet
Author: User
Tags sql server substring

Function:Returns part of a character, binary, text, or image expression.

Syntax:Substring (expression, start, length)

The substring function in SQL is used to capture part of a column. The function names are not exactly the same in different databases:

    • MySQL: substr (), substring ()
    • ORACLE: substr ()
    • SQL Server: substring ()

Parameters:

Expression string, binary string, text, image, column, or expression that contains a column. Do not use expressions that contain aggregate functions.

The START integer or expression that can be implicitly converted to int, which indicates the start position of the stator string.

An integer or expression that can be implicitly converted to an int. It refers to the length of the substring.

return value:

If expression is a supported character data type, character data is returned. If expression is a supported binary data type, binary data is returned. If start = 1, the substring starts with the first character of the expression.

the type of the returned string is the same as that of the given expression (except for the content shown in the following table ).

given expression return type

image

varbinary

ntext

nvarchar

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.