title: TSQL to return what exists
body: <p>This is a follow-up question to this
  <a href="https://stackoverflow.com/questions/68746536/tsql-to-search-text">TSQL to search text</a></p>
  <p>My situation is following</p>
  <pre><code>declare @vendor as table (vName varchar(max))
  insert into @vendor
  select *
  from
  (
      values
          ('Maccro'),
          ('Accro')
  ) t (one)
  
  declare @transaction as table (descr varchar(max))
  insert into @transaction
  select *
  from
  (
      values
          ('recl Maccro something'),
          ('lrec Accro Maccro'),
          ('lrec Maccr0'),
          ('Maccro indeed'),
          ('ACCR Accro'),
          ('Raac else')
  ) t (one)
  </code></pre>
  <p>I can run the following query</p>
  <pre><code>Select 
      a.descr,
      CASE WHEN EXISTS(select * From @vendor b
                       where Charindex(b.Vname, a.descr) &gt; 0)
                then 1 else 0 End [doesContain]
  
  from @transaction a
  </code></pre>
  <p>which returns the following</p>
  <pre><code>| descr                 | doesContain |
  | --------------------- | ----------- |
  | recl Maccro something | 1           |
  | lrec Accro Maccro     | 1           |
  | lrec Maccr0           | 0           |
  | Maccro indeed         | 1           |
  | ACCR Accro            | 1           |
  | Raac else             | 0           |
  </code></pre>
  <p>But is it possible to see on what value it returns 1 for <code>doesContain</code>, i.e. on what value from <code>@vendor</code> table, <code>Exists</code> returns a match.</p>
  <p>My desired output is following</p>
  <pre><code>| descr                 | doesContain | containsWhat |
  | --------------------- | ----------- | ------------ |
  | recl Maccro something | 1           | Maccro       |
  | lrec Accro Maccro     | 1           | Accro        |
  | lrec Maccr0           | 0           |              |
  | Maccro indeed         | 1           | Maccro       |
  | ACCR Accro            | 1           | Accro        |
  | Raac else             | 0           |              |
  </code></pre>