Access Variable Outside Dynamic SQL
Community Wiki answer originally left as question comments

You need:

EXEC sp_executesql
    @sql, 
    N'@value1 varchar(100) OUTPUT',
    @value1=@value1 OUTPUT;


An online demonstration of the technique: http://rextester.com/GDL49591