查找并替换列中的特定字符串 [英] Find and replace particular string in a column
本文介绍了查找并替换列中的特定字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中有一个表,其中包含一些用户名。将数据库文件从一台计算机复制到另一台计算机时,需要手动更新此表。该表包含以下格式的用户名
I have a table in the database where it contains some of the user name. When I copy the database files from one machine to other machine, I need to manually update this table. The table contains the username in the following format
<domain name>\Username
域大多是本地计算机名(用户存在于系统中)。我正在尝试编写一个简单的SQL查询来查找模式(机器名称)并用新的替换。
the domain mostly the local machine name (the user exists within the system). What I am trying to write a simple SQL Query to find a pattern (machine name) and replace with a new one.
我不太精通SQL查询。您可以共享一个示例代码段吗?我正在使用SQL Server 2008
I am not so proficient with SQL queries. Can you share a sample snippet? I am using SQL Server 2008
推荐答案
UPDATE table_that_contains_users
SET field_user = replace( field_user, 'OLDDOMAIN\', 'NEWDOMAIN\')
是吗?
这篇关于查找并替换列中的特定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文