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 更新多个列?
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 在多列上分布任意行 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
