title: Find all rows with the same exact relations as provided in another table
body: <p>Given these tables:</p>
  
  <hr>
  
  <p>Table: Test</p>
  
  <p>Columns: </p>
  
  <ul>
  <li>testID int PK</li>
  <li>name nvarchar(128) UNIQUE NOT NULL</li>
  </ul>
  
  <hr>
  
  <p>Table: [Test-Inputs]</p>
  
  <p>Columns</p>
  
  <ul>
  <li>inputsTableName nvarchar(128) UNIQUE PK</li>
  <li>testID int PK FK</li>
  </ul>
  
  <hr>
  
  <p>Temporary Table: ##TestSearchParams</p>
  
  <p>Columns:</p>
  
  <ul>
  <li>inputsTableName nvarchar(128) UNIQUE NOT NULL</li>
  </ul>
  
  <hr>
  
  <p>I need to find Tests that have entries in Test-Inputs with inputsTableNames matching EXACTLY ALL of the entries in ##TestSearchParams; the resulting tests relationships must be exactly the ones listed in ##TestSearchParams.</p>
  
  <p>Essentially I am finding tests with ONLY the given relationships, no more, no less. I am matching names with LIKE and wildcards, but that is a sidenote that I believe I can solve after the core logic is there for exact matching.</p>
  
  <p>This is my current query:</p>
  
  <pre><code>Select *
  From   Tests As B
  Where  B.testID In (
                         Select ti
                         From   (
                                    Select   (
                                                 Select Count(inputsTableName)
                                                 From   [Test-Inputs]
                                                 Where  [Test-Inputs].testID = B.testID
                                             ) - Count(Distinct i1) As delta,
                                             ti
                                    From     (
                                                 Select [Test-Inputs].inputsTableName As i1,
                                                        [Test-Inputs].testID As ti
                                                 From   ##TableSearchParams
                                                 Join   [Test-Inputs]
                                                     On [Test-Inputs].inputsTableName Like ##TableSearchParams.inputsTableName
                                                        And B.testID = [Test-Inputs].testID
                                             ) As A
                                    Group By ti
                                ) As D
                         Where  D.delta = 0
                     );
  </code></pre>
  
  <p>The current problem is that his seems to retrieve Tests with a match to ANY of the entries in ##TableSearchParams. I have tried several other queries before this, to varying levels of success. I have working queries for find tests that match any of the parameters, all of the paramters, and none of the parameters -- I just cant get this query working.</p>
  
  <p>Here are some sample table values:</p>
  
  <p>Tests</p>
  
  <ul>
  <li>1, Test1</li>
  <li>2, Test2</li>
  <li>3, Test3</li>
  </ul>
  
  <p>[Test-Inputs]</p>
  
  <ul>
  <li>Table1, 1</li>
  <li>Table2, 2</li>
  <li>Table1, 3</li>
  <li>Table2, 3</li>
  </ul>
  
  <p>TestSearchParams</p>
  
  <ul>
  <li>Table1</li>
  <li>Table2</li>
  </ul>
  
  <hr>
  
  <p>The given values should only return (3, Test3) </p>