I have 2 tables in SQL Server:
Table1
ID SkillSetRequired SkillDesc
1 100-1,101-1,102-2,103-3 null
2 100-4,105-2 null
3 100-1,102-2,104-2 null
4 100-5,102-2 null
5 105-1 null
Table2
ID SkillName
100 .Net
101 Java
102 JQuery
103 Sql
104 PHP
105 C
I need to update the SkillDesc column of Table1 with the SkillNames. For example in first row I need to update skilldesc as '.Net,Java,Jquery,SQL'
How can I do this with out using cursors?
I am getting the result in a string from the below query for a single record. But I need to update all the rows.
declare @result varchar(max)
SET @result = ''
SELECT @result = @result + ltrim(rtrim(SkillName)) + ',' from #Table2 where id in(
select SUBSTRING(items, 0 + 1, CHARINDEX('-', items, 1) - 0 - 1) from split('100-1,101-1,102-2,103-3',','))
select @result