title: Update multiple rows based on multiple values
body: <p>Lets say I have this:</p>
  
  <pre><code>Declare @passRefID as int
  Declare @passTextA as varchar
  Deckare @oassTextB as varchar
  Declare @passPropertyA as int
  Declare @passPropertyB as int
  
  
  Set @oassTextA = 'Joe'
  Set @passTextB = 'Smith'
  Set @passPropertyA = 21
  Set @passPropertyB = 23
  </code></pre>
  
  <p><strong>TSQL A:</strong></p>
  
  <pre><code>Set @passRefID = Select Ref_ID from TableA where ID = 10
  </code></pre>
  
  <p>The <code>Ref_ID</code> returns a value of 50</p>
  
  <p>Now I want to use that value in another select statement which returns any amount of rows.
  It looks like this </p>
  
  <p><strong>TSQL B:</strong></p>
  
  <pre><code>Select UserID from TableB where FK_RefID = @passRefID
  </code></pre>
  
  <p>So lets say it returns:</p>
  
  <pre><code>UserID
  34
  56
  87
  </code></pre>
  
  <p>Now I want to create an update for <code>TableC</code> based on the <code>UserID</code> that return previously.</p>
  
  <p>My <strong>TableC</strong> layout of records look like this:</p>
  
  <pre><code>ID,   UserID, PropertyDefinitionID, PropertyValue
  265,  34,     21,                    Bob
  266,  34,     23,                    Barker
  271,  34,     55,                    bb@abc.com
  628,  56,     21,                    Jane
  629,  56,     23,                    Adams
  635,  56,     55,                    ja@abc.com
  901,  83,     21,                    Tom
  905,  83,     23,                    Thumb
  910,  83,     55,                    tt@abc.com
  </code></pre>
  
  <p>I know I can use:</p>
  
  <pre><code>Update TableC Set PropertyValue = @oassTextA Where UserID = 34 and PropertyDefinitionID = @passPropertyA
  Update TableC Set PropertyValue = @oassTextB Where UserID = 34 and PropertyDefinitionID = @passPropertyB
  Update TableC Set PropertyValue = @oassTextA Where UserID = 56 and PropertyDefinitionID = @passPropertyA
  Update TableC Set PropertyValue = @oassTextB Where UserID = 56 and PropertyDefinitionID = @passPropertyB
  Update TableC Set PropertyValue = @oassTextA Where UserID = 83 and PropertyDefinitionID = @passPropertyA
  Update TableC Set PropertyValue = @oassTextB Where UserID = 83 and PropertyDefinitionID = @passPropertyB
  </code></pre>
  
  <p>But my problem is that in <strong>TSQL B</strong>, those rows returned could differ. There could be 1 row or 100 rows returned and the <strong>TableC</strong> is constructed a bit different from the norm.</p>
  
  <p>How can I create a dynamic <code>UPDATE</code> statement based on the amount of rows return using the unique USERIDs and the way the TableC uses the PropertyDefinitionID?</p>
  
  <p>Thanks for your assistance.</p>