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 更新多个列?


- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01