title: user defined type variable is not clearing the value inside the transaction
body: <p>I have scenario to use the Temporary user defined type variable in transaction, but the temporary variable is not clearing the value inside the transaction.</p>
  
  <pre><code>CREATE TYPE [int_list_table] AS TABLE([item_id] [int] NULL) 
  GO
  
  DECLARE @int_val BIGINT
  
  -- Create a Temp table with 5 rows
  ;WITH TEMP(int_val)
  AS
  (SELECT 1
      UNION ALL
  SELECT int_val = 1 + int_val FROM TEMP WHERE int_val &lt; 5
  )SELECT * INTO #int FROM TEMP;
  
  SET NOCOUNT ON
  
  DECLARE IntCursor CURSOR FAST_FORWARD FOR
  SELECT int_val FROM #int
  
  OPEN IntCursor
  FETCH NEXT FROM IntCursor INTO @int_val
  
  WHILE(@@FETCH_STATUS = 0)
  BEGIN
  
      BEGIN TRY
          BEGIN TRANSACTION
  
          -- a temprory table to store the integer value
          DECLARE @table [int_list_table]
          INSERT INTO @table
          SELECT 1 WHERE 2 = @int_val         
          -- Actually @table should have resultset only at @int_val = 2, But once it filled with values even for 3 and 4
          SELECT 
              'User Table Type Value' = item_id,
              'Loop Integer Value' = @int_val
          FROM 
              @table          
          COMMIT TRANSACTION 
      END TRY    
      BEGIN CATCH
          ROLLBACK 
      END CATCH   
      FETCH NEXT FROM IntCursor INTO @int_val
  END
  CLOSE IntCursor
  DEALLOCATE IntCursor
  SET NOCOUNT OFF
  </code></pre>
  
  <p>For the above query the output is </p>
  
  <p><img src="https://i.stack.imgur.com/uISs8.png" alt="Actually it has to return only the record for 2, but it is not clearing the value once it is initialized. Please guide me to proceed further. "></p>
  
  <p>Actually it has to return only the record for 2, but it is not clearing the value once it is initialized. Please guide me to proceed further. </p>