我的數據庫中有一個表
select * from #t1
DESC1
----------------------------------------
底蓋 不銹鋼 C-375
外箱 雙坑 A=B 17-3/8*13-3/4*7-7/8 "
紙箱 單坑 B33 13-1/4*4-1/8*7-1/8 "
外箱 雙坑 A=B 17-1/8*15-7/8*6-3/8 "
紙箱 單坑 B33 16-5/8*5*5-5/8 "
單平咭B3B 12-7/8*3-7/8 "
單平咭B3B 6-3/4*3-7/8 "
單平咭B3B 16-1/8*4-5/8 "
單平咭B3B 4-5/8*5-1/8 "
外箱 雙坑 A=B 17-3/8*13-3/4*7-7/8 "
(10 row(s) affected)
但是,
select * from #t1 where patindex( '%外箱% ',DESC1) <> 0
很明顯是有結果的,但是
結果是:
DESC1
----------------------------------------
(0 row(s) affected)
我測試了一下
SELECT PATINDEX ( '%外箱% ', '外箱外箱 ')
結果:
-----------
1
(1 row(s) affected)
後來,我為了進一測試,我把desc0 改為varchar(1000)
create table #t2
(
desc0 nvarchar(1000) collate Latin1_General_BIN
)
insert into #t2
select '張鴻亮C-375 ' union all
select '外箱 雙坑 A=B 17-3/8*13-3/4*7-7/8 " ' union all
select '紙箱 單坑 B33 13-1/4*4-1/8*7-1/8 " ' union all
select '外箱 雙坑 A=B 17-1/8*15-7/8*6-3/8 " ' union all
select '紙箱 單坑 B33 16-5/8*5*5-5/8 " ' union all
select '單平咭B3B 12-7/8*3-7/8 " ' union all
select '單平咭B3B 6-3/4*3-7/8 " ' union all
select '單平咭B3B 16-1/8*4-5/8 " ' union all
select '單平咭B3B 4-5/8*5-1/8 " ' union all
select '外箱 雙坑 A=B 17-3/8*13-3/4*7-7/8 " '
select * from #t2
結果:
???C-375
?? ?? A=B 17-3/8*13-3/4*7-7/8 "
?? ?? B33 13-1/4*4-1/8*7-1/8 "