I meant in the first exec.
Don't know the exact explanation, but it is like it is executed in a diferent context or connection.
If you create a #temp table with EXEC (EXEC ('CREATE #TABLE...')) you won't see it in the actual connection, the same if you declare variables
EXEC ('DECLARE @test-2 AS INT SELECT @test-2 = 1')
PRINT @test-2
this will fail,
EXEC ('DECLARE @test-2 AS INT SELECT @test-2 = 1 PRINT @test-2')
This won't.