Learning Learning - 5 months ago 9
SQL Question

Replace comma with with different comma ، in database field

I have a field in a table where I store multiple tags separated with comma for example

tag1, tag2, tag3,tag4


I need to replace a single comma with
،
for Persian version
so that tags will look like

tag1، tag2، tag3،tag4،


I have over three thousand records in the database and tags are stored with either
،
or
,
but I want all of them to be separated with
،
.

How can I find and replace all
,
with
،
using SQL.

I am using SQL Server as my database.

Let us say table structure is

Table BLOG

BLOG Table fields

ID int
Title nVarchar(300)
Description nVarchar(500)
Details nVarchar(max)
Date DateTime
Tags nVarchar(300)
Image varchar(60)
CategoryID int
Updated DateTime
Created DateTime
Published Boolean

Answer

Have you tried using REPLACE():

Update BLOG
SET Tags = REPLACE(Tags, ',', N'،')