• The problem here is that the variables are declared outside the scope of the dynamic SQL statement...either declare the variable within the dynamic SQL (this might not be of any use) or get the results of the dynamic into a table/temp table (this might be of more use)

    declare @lstr varchar(200)

    set @lstr = 'declare @word varchar(20) select top 1 @word = name from sysobjects select @word'

    exec(@lstr)

    or

    DECLARE @Results TABLE(result sysname)

    INSERT @Results(result)

    EXEC('select top 1 name from sysobjects')

    SELECT * FRM @Results