Sunday, February 5, 2023

SQL Server Function

 STUFF :

The STUFF() function deletes a part of a string and then inserts another part into the string, starting at a specified position.

Note: Also look at the REPLACE() function.

Syntax:

STUFF(stringstartlengthnew_string)


Example: 

SELECT STUFF('SQL Tutorial!'131' is fun!');


CharIndex()

The CHARINDEX() function searches for a substring in a string, and returns the position.

If the substring is not found, this function returns 0.

Note: This function performs a case-insensitive search.

Syntax:

CHARINDEX(substringstringstart).

Example:

SELECT CHARINDEX('OM''Customer'AS MatchPosition




No comments:

Post a Comment

How to use SQL pagination using LIMIT and OFFSET

  How to extract just a portion of a larger result set from a SQL SELECT. LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY. T...