I try to create #temp table from another #temp table then it's through the error.
Set @Query = 'Select Work_Order_No,ServiceCode,StageNo,ItemWeight,StagePercentage,FebLocation
INTO #TempMaster
FROM #Temp '
EXEC(@Query)
Above query throw the error
Invalid object name '#TempMaster'.
and if I execute this query
Set @Query = 'Select Work_Order_No,ServiceCode,StageNo,ItemWeight,StagePercentage,FebLocation
INTO ##TempMaster
FROM #Temp '
EXEC(@Query)
Then it's working fine. What is different between these two statement. What is reason that first query throw error and second query run successfully.
EXEC(@Query), specifically when you are attempting to read from the table specified in the dynamic query'sINTOclause.