If anybody looking for similar things here is the solution.
I needed a custom split function to separate the delimited list, and then use FOR XML PATH to combine the descriptions. Here is the final query
select t1.Name,
STUFF(( SELECT ', ' + Description
FROM table2 AS t2
WHERE t2.ruleNumber in (select s from dbo.SplitFunction(t1.RuleNumber, ','))
ORDER BY ruleNumber
FOR XML PATH('')), 1, 1, '') as 'Description'
from table1 t1
Here is the code for the split function.
create function [dbo].[SplitFunction]
(
@String varchar(8000) ,
@Delimiter varchar(10)
)
returns @tbl table (s varchar(1000))
as
begin
declare @i int ,
@j int
select @i = 1
while @i <= len(@String)
begin
select @j = charindex(@Delimiter, @String, @i)
if @j = 0
begin
select @j = len(@String) + 1
end
insert @tbl select substring(@String, @i, @j - @i)
select @i = @j + len(@Delimiter)
end
return
end