Get the App
SLTechnology News&Howtos  ›  Database  › 

The usage of SQL Server stuff function

Shulou Source: shulou.com Published: 2022-06-01 09:53:13 09月12日 Update

1. Function

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

2. Grammar

STUFF (character_expression, start, length, character_expression2)

3. Explanation

Character_expression is the string to be processed

Start is the starting position of the deleted character, and the string starts at 1. If you want to delete from the second character, the start is 2.

The length of the character to be deleted by length. If you delete from the second character and delete three characters, the length is 2.

Character_expression2 wants to replace the deleted string (it's a bit of a mouthful, but it's not hard to understand)

4. Examples

If the preprocessed string character_expression is' abcdef', wants to delete 'cde', the stuff function is written as follows:

Stuff ('abcdef',3,3,'')

If you want to replace 'cde' with' xyz', the stuff function is written as

Stuff ('abcdef',3,3,'xyz')

Tags: Character string function writing length mouthful three position function example grammar starting point starting point processing preprocessing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple Xiaomi Shulou Tech Info Shulou Technology