sql - Compare Part of String 1 with the Second string -


i have 2 string columns below

column01               column02  abc school system      worked in private school.  

i want match these columns such if single word columns available in column b gives match result. in case word "school" present in both columns should considered match.

a single word column can defined string of letters length of more 3 , having spaces @ both sides or having space @ either of 1 side , nothing on other side (to cater starting , closing word).

how can in sql server?

you create xml using space token , using .nodes() words xml column , compare them together. this

with table1  (     select 1 id,'abc school system' col1, 'worked in private school'  col2  ), cte2  (     select m.id,c.value('text()[1]','varchar(100)') collate latin1_general_ci_as col1val,c2.value('text()[1]','varchar(100)') collate latin1_general_ci_as  col2val         (         select id,         convert(xml,'<i>' + replace(col1,' ','</i><i>') + '</i>') col1,         convert(xml,'<i>' + replace(col2,' ','</i><i>') + '</i>') col2         table1     )m     cross apply col1.nodes('i') t(c)     cross apply col2.nodes('i') t2(c2) ) select id,col1val,col2val cte2 col1val = col2val     , len(col1val) > 3     , len(col2val) > 3 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -