Usage of STUFF and SQLSTUFF in SQL

Source: Internet
Author: User

Usage of STUFF and SQLSTUFF in SQL

1. Role

Delete characters of the specified length and insert a group of characters at the specified start point.

2. Syntax

STUFF ( character_expression , start , length ,character_expression )

3. Example

The following example deletes the three characters starting from the first position (character B) in abcdef, and inserts the second string at the start of the deletion to create and return a string.

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

The following is the result set.

Aijklmnef

4. Parameters

Character_expression

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

Start

An integer that specifies the start position of 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 of the bigint type.

Length

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

5. Return type

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

6. Remarks

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

The above section describes the usage of STUFF in SQL. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.