Insert Records in Temp Table for running another Query

Hi

I want to Insert Records in Temp Table for running another Query in same Stored Procedure

Thanks

You could create Temp table as
CREATE TABLE #TMP(YourCOL TYPE)
or
DECLARE @TMP AS TABLE(YourCOL TYPE)

And can insert records in these temp table before utilizing again in the same store procedure.

You can use "SELECT INTO" command

SELECT * INTO #TempTableName
FROM....

This will create a new table.

Hi

Incorrect syntax near Group. I need all the columns in Temp Table also.

Select * InTo #_Total From(
SELECT a.empid,b.empname,b_empmarks
FROM empmaster a
LEFT OUTER JOIN empdetail b
on a.empid = b.empid
WHERE a.empid =@empid)
GROUP BY a.empid
ORDER BY a.empid

Thanks