Reputation: 1651
How do I achieve the following by a stored procedure or sql script in sql server?
Say for example, I have a-b in one of the columns and I need to update that column to a - b instead. How do I insert spaces before and after the dash in existing data in my database.
Upvotes: 0
Views: 2876
Reputation: 31250
update TableName set ColumnName = Replace(ColumnName, '-', ' - ') where SomeCondition ...
Upvotes: 0
Reputation: 135799
UPDATE YourTable
SET YourColumn = REPLACE(YourColumn, '-', ' - ')
Upvotes: 1