I have a piece of dynamic SQL I need to execute, I then need to store the result into a variable.
I know I can use sp_executesql but can\'t find clear e
sp_executesql
DECLARE @tab AS TABLE (col1 VARCHAR(10), col2 varchar(10)) INSERT into @tab EXECUTE sp_executesql N' SELECT 1 AS col1, 2 AS col2 UNION ALL SELECT 1 AS col1, 2 AS col2 UNION ALL SELECT 1 AS col1, 2 AS col2' SELECT * FROM @tab