将逗号替换为逗号和逗号的列中的函数替换?

时间:2014-06-05 13:11:49

标签: sql-server string tsql replace sql-server-2008-r2

我有一张员工表

EmpGid    Employees
 1          john
 2          john,kevin
 3          Tom,Peter,harry
 4          Peter,Mike,Frank

当我选择员工时,我需要输出如下所示

 Employees
   john
   john','kevin
   Tom','Peter','harry
   Peter','Mike','Frank

       I am using Replace but i am unable replace ',' where , is present .

       Can some one help me how to replace.

2 个答案:

答案 0 :(得分:1)

这将替换为',':

SELECT *, replace(Employees, ',',''',''') FROM Employees

答案 1 :(得分:1)

应该是

select REPLACE('John,Kevin',',',''',''')

这将导致John','Kevin