Try a query:
select replace(replace(MyColumn, ', ', ','), ',', ', ')
from MyTable
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello All
I am new to sql.
I need to give a space after comma in my employee name .
Please suggest how to do.
Data :
Smith,Micheal
Ben,Jeff
Output :
Smith, Micheal
Ben, Jeff
Try a query:
select replace(replace(MyColumn, ', ', ','), ',', ', ')
from MyTable
Hi @Learner ,
According to your data, you could simply use replace function to replace commas with comma + space like below:
update yourtable
set employeename=REPLACE(employeename,',',', ')
If there are also some other extra spaces, you could refer Viorel's answer.
Besides, you could also try with another method like below:
update yourtable
set employeename= STUFF(employeename, CHARINDEX(',', employeename)+1,0, ' ')
Best regards,
Melissa
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.