I have created a procedure
create procedure testProcedure_One
as
DECLARE @Query nvarchar(4000)
begin
SET @Query = 'SELECT * into #temptest FROM Table1'
Exec sp_Executesql @query
SELECT * FROM #temptest
drop table #temptest
end
When I run the procedure testProcedure_One
I am getting the error message:
Invalid object name '#temp'
But if I use ##temp means
it's working:
create procedure testProcedure_two
as
DECLARE @Query nvarchar(4000)
begin
SET @Query = 'SELECT * into ##temptest FROM Table1'
Exec sp_Executesql @query
SELECT * FROM ##temptest
drop table ##temptest
end
testProcedure_two
is working fine
What might be the issue? How can i solve it?