Stuff usage in SQL _mssql

Source: Internet
Author: User
Tags first string

2. Use

Deletes a character of the specified length and inserts another set of characters at the specified starting point.

2. Grammar

STUFF (character_expression, start, length, character_expression)

3, example

The following example deletes three characters starting at position 2nd (character B) in the first string abcdef, and then inserts a second string at the start of the deletion, creating and returning a string

SELECT STUFF (' abcdef ', 2, 3, ' ijklmn ') go

Here is the result set

Aijklmnef

4. Parameter

character_expression

A character data expression. A character_expression can be a constant, a variable, or a character or binary data column.

Start

An integer value that specifies the start position of the deletion and insertion. If start or length is negative, an empty string is returned. If start is longer than the first character_expression, an empty string is returned. Start can be a bigint type.

Length

An integer that specifies the number of characters to delete. If length is longer than the first character_expression, delete up to the last character in the last character_expression. Length can be a bigint type.

5. Return type

If the character_expression is a supported character data type, the character data is returned. If character_expression is a supported binary data type, the binary data is returned.

6, Notes

If the result value is greater than the maximum value supported by the return type, an error is generated.

The above is a small set to introduce the SQL stuff usage, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.