问题描述
如何更新表中的不同列和行?我想做类似于 替换字符串的事情在 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 更新多个列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!