SQL Server 2008 将多个单词替换为单个单词
SQL Server 2008 replace multiple word to single word
在 SQL server 2008 中,我需要将许多 'Pass' 单词替换为单个 'Pass'
'Pass Pass Pass Pass Pass'替换成'Pass'
这里'Pass Pass Pass Pass Pass'可以改。
例如:
'Pass ' => 'Pass'
'Pass Pass ' => 'Pass'
'Pass Pass Pass ' = > 'Pass'
'Pass Pass Pass Pass Pass' => 'Pass'
有什么帮助吗?谢谢
- 编写查询以将 {2 spaces} 替换为 {1 space}" " 并重复 运行 直到 {2 spaces} 不是找到了。
- 编写一个查询,将 PASS PASS 替换为 PASS,然后 运行 重复该查询,直到不再找到 PASS PASS。
如果这是在一个单独的列中,并且 'PASS' 是您在该列中所期望的,那么您可以执行以下操作:-
case
when YourColumn LIKE '%PASS%' then 'PASS'
else YourColumn
end
在 SQL server 2008 中,我需要将许多 'Pass' 单词替换为单个 'Pass'
'Pass Pass Pass Pass Pass'替换成'Pass'
这里'Pass Pass Pass Pass Pass'可以改。 例如:
'Pass ' => 'Pass'
'Pass Pass ' => 'Pass'
'Pass Pass Pass ' = > 'Pass'
'Pass Pass Pass Pass Pass' => 'Pass'
有什么帮助吗?谢谢
- 编写查询以将 {2 spaces} 替换为 {1 space}" " 并重复 运行 直到 {2 spaces} 不是找到了。
- 编写一个查询,将 PASS PASS 替换为 PASS,然后 运行 重复该查询,直到不再找到 PASS PASS。
如果这是在一个单独的列中,并且 'PASS' 是您在该列中所期望的,那么您可以执行以下操作:-
case
when YourColumn LIKE '%PASS%' then 'PASS'
else YourColumn
end