开发者

Detect (find) string in another string ( nvarchar (MAX) )

I've got nvarchar(max) column with different values alike 'A2'

And another column from another table with values alike '(A2 AND A3) OR A4'

I need to detect does string from second column contains string from first column.

So then I need to select all columns of second table which contains an string from first column of first table.

something alike ... but that is wrong

SELECT * Cols FROM T2
WHERE (SELECT T1.StringCol FROM T1) IN T2.StringCol

but I more understand it like it (in f# syntax)

for t1.date, t1.StringCol from t1
 for t2.StringCol f开发者_JAVA百科rom t2
  if t2.StringCol.Contains( t1.StringCol )
    yield t2.StringCol, t1.date


This should get what you want...

select t2.*
from t1 cross join t2
where patindex('%' + t1.StringCol + '%', t2.StringCol) > 0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜