February 4, 2016 at 10:17 am
create table #Source(Column_source varchar(20))
Insert into #Source values('1'),('2')
need to search full word match from #source table column column_source values 1 & 2 with #result table column Column_result
create table #result(column_result varchar(20))
Insert into #result values('223 1'),('122 2 11'),('323 22 1'),('133')
If i join the above two tables i need result set like below, should match full word from source table column values which are 1 & 2
: Results
223 1
122 2 11
323 22 1
need exact full word match result should be like below.. I'm not looking for LIKE operator
February 4, 2016 at 10:24 am
What's wrong with LIKE operator if it does exactly what you're asking for?
SELECT *
FROM #Source s
JOIN #result r ON ' ' + r.column_result + ' ' LIKE '% ' + s.Column_source + ' %'
Further explanation: http://qa.sqlservercentral.com/articles/T-SQL/130558/
February 4, 2016 at 1:53 pm
Luis Cazares (2/4/2016)
What's wrong with LIKE operator if it does exactly what you're asking for?
SELECT *
FROM #Source s
JOIN #result r ON ' ' + r.column_result + ' ' LIKE '% ' + s.Column_source + ' %'
Further explanation: http://qa.sqlservercentral.com/articles/T-SQL/130558/
I does not pick the first value: '223 1'.
Correction: It does, but only for a limited case of a single delimiter, blank space in this case.
_____________
Code for TallyGenerator
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply