I want to run a dynamically created SQL Statement and place results in a temporary table for process later in the Stored Procedure.
This is what I have
DECLARE @sqlStatement AS NVARCHAR(1000)
SET @sqlStatement = 'Select userid into #myusers';
EXECUTE sp_executesql @sqlStatement
I get the error
Invalid object name 'myusers'.
Is there any way around this?
Thanks in advance