By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tablename
([tableName] varchar(3), [duplicate_Id] int, [Index_name] varchar(11), [Column_List] varchar(16))
;
INSERT INTO tablename
([tableName], [duplicate_Id], [Index_name], [Column_List])
VALUES
('foo', 1, 'foo_index_1', 'fafa, fifi, fufu'),
('foo', 2, 'foo_index_2', 'fafa, fifi'),
('bar', 1, 'bar_index_1', 'bubu, bebe'),
('bar', 2, 'bar_index_2', 'bubu'),
('bar', 3, 'bar_index_3', 'bebe')
;
5 rows affected
select t.*,
case when exists (
select 1 from tablename
where Column_list like t.Column_list + ',%'
) then 'true'
else 'false'
end Contained
from tablename t
tableName | duplicate_Id | Index_name | Column_List | Contained |
---|---|---|---|---|
foo | 1 | foo_index_1 | fafa, fifi, fufu | false |
foo | 2 | foo_index_2 | fafa, fifi | true |
bar | 1 | bar_index_1 | bubu, bebe | false |
bar | 2 | bar_index_2 | bubu | true |
bar | 3 | bar_index_3 | bebe | false |