I have a stored procedure that creates a temp table and then populates the table from a stored procedure, like below: -
CREATE TABLE #Table
SET ARITHABORT ON
EXEC dbo.ProcName @Param1, @Param2, @Parem3
SET ARITHABORT OFF
If I run dbo.ProcName on its own, it takes 2 seconds to return. If I run the stored proceure with the create table and then execute the stored proc, it takes approx 2 minutes to complete.
Can anyone shed any light on this or provide a more efficient way of doing this?