title: subtract variables in SQL
body: <p>How can I subtract values in two variables. Here is what I have done so far</p>
  
  <pre><code>DECLARE @A NVARCHAR(MAX)
  DECLARE @B NVARCHAR(MAX)
  
  SET @A='select count(abc)
   from x'
   EXEC (@A)
   PRINT @A
  
   SET @B= ' select count(xyz)
   from  y'
  
   EXEC (@B)
   PRINT @B
  
   DECLARE @C INT
   SET @C = CAST(@A AS INT) - CAST(@B AS INT)
   EXEC (@C)
   PRINT @C
  </code></pre>
  
  <p>I am getting conversion error</p>
  
  <blockquote>
    <p>Msg 245, Level 16, State 1, Line 20<br>
    Conversion failed when converting the nvarchar value</p>
  </blockquote>