RSS Feed

SQL Stuff()

SQL Stuff()

STUFF() function returns a string formed by deleting a specified number of characters from String_expression1 and replacing them with String_expression2. For deletion you have to specify Start_position and length.

SQL Stuff() Syntax

STUFF (String_expression1, start_position, length, String_expression2)

Example 1 of SQL STUFF()

SELECT STUFF('1234567', 2, 3, '999');

1999567

Example 2 of SQL STUFF()

SELECT STUFF('1234567', 2, 3, '9999');

19999567

Example 3 of SQL STUFF()

SELECT STUFF('1234567', 2, 3, '9999999');

19999999567

Example 4 of SQL STUFF()

SELECT STUFF('1234567', 2, 0, '999');

1999234567

Example 5 of SQL STUFF()

SELECT STUFF('1234567', 0, 0, '999');

NULL

Example 6 of SQL STUFF()

SELECT STUFF('1234567', 1, 0, '999');

9991234567

Example 7 of SQL STUFF()

SELECT STUFF('1234567', 1, 1, '999');

999234567


Also See:
SQL Replace

No comments:

Post a Comment