April 4, 2016 at 4:07 am
Hi,
i have two table like below.
Table1
IdName
1a,b,c
2b,c
3c,d
4a,b,c,d
Table2
IdName
aaaa
bbbb
cccc
dddd
the output should be the following..
Output:
id name
1aaa,bbb,ccc
2bbb,ccc
3ccc,ddd
4aaa,bbb,ccc,ddd
Please let me know if any body knows..
April 4, 2016 at 4:11 am
Honestly, you should first be looking at normalising the table design. The first is not normalised and hence you have these kinds of problems.
To solve it in the mean time, get the function DelimitedSplit8k (it's from an article on this site, google will find it) and use that to split the comma-delimited list up. You can then join with a LIKE predicate.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply