Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 526.6k

Invalid Object Name #temp

Apr 29 2023 7:31 AM

Hi

  In below code on select * from #temp. it is giving above erro

set @query = 'select [BookId] [Book ID],BookTitle [Book],[ComboBookName],[CoreRPL],[Lexile],[NumberOfPages],[SessionPlanStatus],[ClosingStock], ' + @cols + '
	INTO #temp from (select [BookID] ,BookTitle,[ComboBookName],[CoreRPL],[Lexile],[NumberOfPages],[SessionPlanStatus],Status,[ClosingStock],StudentName from #finalTable
	where (('''+@BookID+'''=''0'' OR [BookId] IN('+ cast(@BookID as varchar(Max))+')))) x pivot
	( Max(Status) for StudentName in (' + @cols + ')) piv order by BookTitle';
	--print @query
	--execute (@query)
	select * from #temp

Thanks


Answers (2)