The most complete and secure solution I found was the following:
declare @aux_col varchar(255)
SELECT @aux_col = colaboradores FROM controles WHERE id = 1 --id do treinamento selecionado
-- esses três passos são necessários de acordo com os caracteres especiais mostrados no exemplo
select @aux_col = replace(@aux_col, '[', '')
select @aux_col = replace(@aux_col, ']', '')
select @aux_col = replace(@aux_col, '"', '')
-- esse passo é para facilitar a pesquisa, onde será sempre consultada a string ,codigo,
select @aux_col = ',' + @aux_col + ','
SELECT s.nome as setor, count(*) as quantidade
FROM colaboradores c
JOIN setores s on s.id = c.setor
WHERE LOCATE(',' + c.id + ',', @aux_col) > 0
GROUP BY s.nome
ORDER BY s.nome
Validation on locate
using comma before and after id
is required because if it did not exist, searching for code 1
would return true if code 11
existed, for example.