Sorry, I don't think that your query will work. You cannot insert into a table variable from inside a dynamic query. Try the following:
declare @test table ( MyId int )
insert into @test values (5)
declare @stmt varchar(128)
set @stmt = 'insert into @test values (6)'
exec( @stmt )
The dynamically executed statment will not work because it does not know about the table var @test.
Additionally I saw that you forgot the ( ) in your exec-statement.
exec @querystring cannot execute a dynamic query; you have to write
exec ( @querystring ). Otherwise SQL Server will think you want to execute a stored procedure with the name stored in @querystring. See Transact-SQL-Reference for EXECUTE in Books Online for details.
Visit my blog at http://www.cubido.at/rainers