Stop SQL Server 2012 From Highlighting Implicitly Passed Temp Tables "Invalid Object" I tend to use Temp Tables to pass large amounts of data from one stored procedure into another stored procedure. However, something that's always annoyed me is that, because it's implicitly passed/shared with the session, the sub stored procedure has no knowledge of it and constantly highlights table/column references as "Invalid Object".

Is there any way to "force" knowledge of a Temp Table's schema into a stored procedure?

--Yes, this is awful.  Quick and dirty pseudo code.
create procedure usp_myProc
(
    create table #temp
    (
        id int
        ,data int
    )

    insert into #temp(id, data)
    values(1, 1)

    exec usp_mySubProc;
)

create procedure usp_mySubProc
(
    --#temp and Data will both be highlighted as Invalid Objects
    --Because I'm updating the table, a Table Valued Parameter won't work
    while(1)
    (
        update
            #temp
        set
            Data = 1
    )
)
Is there any way to "force" knowledge of a Temp Table's schema into a Stored Proc?
  


You could pass the data using a Table-Valued Parameter instead.  Or you could try something like this:

create proc usp_myProc
as
begin
    create table #temp
    (
        id int
        ,data int
    )

    exec usp_mySubProc;
end
go

create proc usp_mySubProc
as 
begin

    --table creation will be skipped at runtime
    if 1=0 create table #temp(id int, data int)

    update
        #temp 
    set
        data = 1

end
go