DECLARE @m nvarchar(max) SET @m = N'DECLARE @t TABLE (ID int);INSERT INTO @t VALUES (1);SELECT * FROM @t T' EXEC sp_executesql @m