REPLACE Function In SQL Server 2008

In this article i will explain how to use REPLACE Function in SQL.
  • 2685

Introduction

STUFF() function is used to replaces all occurrences of a string with new characters.

Syntax

REPLACE (InputString, StringToReplace, NewString)

where,

InputString- Input string specifies the string in which replacement is to be done.
StringToReplace- Specifies the sequence of characters to be replaced.
NewString- New string replaced to original string

Example

Suppose we have table named Employee as.

CreateTable-in-sqlserver.jpg

Replace all occurrence of "agarwal" in L_Name column with "KAPOOR".

SQL-REPLACE-function.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.