SQL Replace comma in results without using replace SQL Replace comma in results without using replace sql-server sql-server

SQL Replace comma in results without using replace


I believe you may be confused as to what the REPLACE function is doing. You can use REPLACE within your SELECT statement without altering the data in the database:

SELECT REPLACE(MyField, ',', ';') AS NewFieldNameFROM MyTable


I believe you don't want to replace the value physically in the table, but ok to replace on select

So you can

Select REPLACE(ColumnName,',',';') From TableName


Most SQL servers implement an inline replace function. Most of them are named replace(), and can also be used in a select statement. Example from MySQL:

SELECT field, REPLACE(field,',',';') FROM my_table;