当前位置: 代码迷 >> Sql Server >> 一条SQL2000字符串匹配的有关问题
  详细解决方案

一条SQL2000字符串匹配的有关问题

热度:84   发布时间:2016-04-24 10:15:54.0
一条SQL2000字符串匹配的问题!
本帖最后由 lolaceramd 于 2014-07-21 23:28:44 编辑
两个表sheet1和sheet2
sheet1内由于各种原因,字符串损坏了,个别字符变成“问号”了,sheet2内是完好的,可不可以将sheet2内完好的字符串给sheet1 进行替换。

sheet1:
name
abcd?
a?ee
?eecd
123?4
11222?d

sheet2:
name
scll
ADc
abcde
abee
1h3h
aeecd
123d4
11222ed
------解决方案--------------------
select patindex('%a_B%' ,'adadfacb')
go 
use tempdb
go
create table temp2
(
name nvarchar(100)
)
create table temp1
(
name nvarchar(100)
)
go

insert into temp1([name])
select 
'name'
union select
'abcd?'
union select
'a?ee'
union select
'?eecd'
union select
'123?4'
union select
'11222?d'
go
insert into temp2([name])
select 
'name'
union select 
'scll'
union select 
'ADc'
union select 
'abcde'
union select 
'abee'
union select 
'1h3h'
union select 
'aeecd'
union select 
'123d4'
union select 
'11222ed'
go
select * from temp1 a inner join temp2 b on PATINDEX('%'+Replace(a.name,'?','_')+'%',b.name)>0
  相关解决方案