title: Call update stored procedure in insert stored procedure if record exists
body: <p>I am trying to call a stored procedure in another. The issue is that both use the same variables. How do I get them in the embedded procedure?</p>
  
  <pre><code>CREATE PROCEDURE uspInsert @foo int, @bar int, @cat bit
      SET @recId = (SELECT TOP(1) id FROM table WHERE foo = @foo)
      IF (@recId IS NULL)
          BEGIN INSERT INTO table
          END
      ELSE
          BEGIN
              EXEC uspUpdate @foo = @foo, @bar = @bar, @cat = @cat
          End
  </code></pre>
  
  <p>Update proc</p>
  
  <pre><code>CREATE PROCEDURE uspUpdate @foo INT, @bar INT, @cat BIT;
  </code></pre>