Search code examples
sqlsql-serversql-server-2014

SQL Server 2014: Add space after comma


I want to update only the values in Column1 that have characters of a string, then a comma, then (without a space) more characters, like so: abc,def or abc,123,def. I want a space to be added between the comma and the next character, like so: abc, def or abc, 123, def. It shouldn't add an extra space if there already is one.

Sorry, I don't have any existing SQL to show-- I'm not sure where to even start on this.


Solution

  • I'd first replace all instances of , (comma + space) with , (comma, NO space). That way everything is uniform. Then go the other way; replace commas with comma + space