REPLACE Function in SQLServer

Have you ever needed to change part of a string in SQL Server? I have seen this come up in a variety of situations, like needing to change local IIS port to QA IIS port number so that to show image. The basic code is as follows:

REPLACE(YourString, ‘text to replace’, ‘replace with text’)

Below is a practical example of how useful this can be.

When copied and paste all records from a table to another table but forget to change the local port. So I used Replace to change the port 85 to port 87 in the column picture:


Using REPLACE in SQL Server, you can quickly update the port number to show images in a web execute this script against the new table :

update AutoUsed set picture = REPLACE(picture, '85', '87')

No results found

jPList Actions