title: SQL server: Question about query group and auto id
body: <p>i have a table  which has 2 columns like this, picture is input and output:</p>
  <p><a href="https://i.stack.imgur.com/NL0Oh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NL0Oh.png" alt="enter image description here" /></a></p>
  <p>Explain input: 2 column is 2 person who relation ship together. Exam: A relation with B, C,D,H
  Output: i want to merge 2 column , with Column group ID auto and column RelationShip</p>
  <ul>
  <li>ID group auto: i tried query: row_number() OVER (ORDER BY [columnA]) n</li>
  <li>RelationShip: is group all person relatioship together and group them to 1 ID group. Exam person A,B,C,D,H realation ship together and group id auto is 1</li>
  </ul>
  <p>I have a demo in <a href="https://dbfiddle.uk/?rdbms=sqlserver_2019&amp;fiddle=f81ff386b07589654ad133a8e4b30472" rel="nofollow noreferrer">https://dbfiddle.uk/?rdbms=sqlserver_2019&amp;fiddle=f81ff386b07589654ad133a8e4b30472</a></p>
  <p>In my query, first i turn the data into a single column, second i count letter, next step i don't know query.</p>
  <p>I tried recursive CTE but error (perhaps I don't understand clearly about recursive)</p>
  <p>I want to solve this problem in sql query.</p>