title: T-SQL Return All 3-Way Combinations of a Table
body: <p>I have a relatively simple problem but cannot seem to find the solution. This is how my table looks like:</p>
  <pre><code>+---------+----------+
  | Article | Supplier |
  +---------+----------+
  |    4711 | A        |
  |    4712 | B        |
  |    4712 | C        |
  |    4712 | D        |
  |    4713 | C        |
  |    4713 | E        |
  +---------+----------+
  </code></pre>
  <p>Now, I want to find all possible 3-way combinations. Each article has to be included in each group (4711, 4712, 4713). For the example above, we will get 6 combination pairs and 18 datasets. The result should look like as follows:</p>
  <pre><code>+----------------+---------+----------+
  | combination_nr | article | supplier |
  +----------------+---------+----------+
  |              1 |    4711 | A        |
  |              1 |    4712 | B        |
  |              1 |    4713 | C        |
  |              2 |    4711 | A        |
  |              2 |    4712 | B        |
  |              2 |    4713 | E        |
  |              3 |    4711 | A        |
  |              3 |    4712 | C        |
  |              3 |    4713 | C        |
  |              4 |    4711 | A        |
  |              4 |    4712 | D        |
  |              4 |    4713 | E        |
  |              5 |    4711 | A        |
  |              5 |    4712 | D        |
  |              5 |    4713 | C        |
  |              6 |    4711 | A        |
  |              6 |    4712 | D        |
  |              6 |    4713 | E        |
  +----------------+---------+----------+
  </code></pre>
  <p>I would really appreciate some help.</p>