开发者

Update column to insert spaces in one of the columns in sql server table

开发者 https://www.devze.com 2023-02-14 21:48 出处:网络
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 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 da开发者_高级运维tabase.


UPDATE YourTable
    SET YourColumn = REPLACE(YourColumn, '-', ' - ')


update TableName set ColumnName = Replace(ColumnName, '-', ' - ') where SomeCondition ...
0

精彩评论

暂无评论...
验证码 换一张
取 消