How can I update multiple columns with a Replace in SQL server?(如何在 SQL Server 中使用 Replace 更新多个列?)
问题描述
如何更新表中的不同列和行?我想做类似于 替换字符串的事情在 SQL 服务器中
How do I update different columns and rows across a table? I want to do something similiar to replace a string in SQL server
我想这样做,但该值存在于同一类型的多个列中.这些值是员工表的外键 varchars.每列代表一个任务,因此同一员工可能被分配到记录中的多个任务,并且这些任务在记录之间会有所不同.我怎样才能有效地做到这一点?基本上可以替换整个表中不同列的所有内容.
I want to do this but the value exists in multiple columns of the same type. The values are foreign keys varchars to an employee table. Each column represents a task, so the same employee may be assigned to several tasks in a record and those tasks will vary between records. How can I do this effectively? Basically something of a replace all accross varying columns throughout a table.
感谢您的任何帮助或建议.
Thanks for any help or advice.
干杯,~ck 在圣地亚哥
Cheers, ~ck in San Diego
推荐答案
这应该可以解决问题:
UPDATE table1
SET field1 = replace(field1, 'oldstring', 'newstring'),
field2 = replace(field2, 'oldstring2', 'newstring2')
等等……
这篇关于如何在 SQL Server 中使用 Replace 更新多个列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 SQL Server 中使用 Replace 更新多个列?


基础教程推荐
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01