In this article, we will look into the PostgreSQL's "Overlay" function and it's equivalent implementation in Sql Server 2012.

Introduction

PostgreSQL is a powerful open source RDMBS and is a good repository of a handful of functions. In this article, we will look into the "Overlay" function and it's equivalent implementation in Sql Server 2012.

Purpose

To replace substring from a specified position to a specified position.

Syntax

Overlay(string placing string from int [for int])

Example of Overlay function in PostgreSQL

As can be figure out that "anda" has been replaced by "funda". The replacement started from position 11 and should continue till 4 since the length of "anda" is 4.So the characters between 11 to 15 (11+4) are "anda" and those should be replaced by "funda". Though we don't have in our SQL Server such a function, but we can always create our own. Here is my attempt