How to deal with temp tables when compiling databa

2019-05-22 15:27发布

We just created a solution with multiple data projects. We inherited the system and want to do a database cleanup but when we compile some of the databases we get the error that table, id etc does not exist and it occures where temp tables are created in stored procedures.

Let's say a stored proc creates a temp table and at the end drops it the compiler complains and says that the table does not exist (in the database schema). How can we work around this? Any settings I can't find?

Thanks in advance.

1条回答
Summer. ? 凉城
2楼-- · 2019-05-22 16:09

There is a bug filed in Microsoft Connect on this issue, and there is a workaround suggested: use table variables instead of temporary tables. So, use

declare @t table (ID int, Name nvarchar(100) )
insert into @t ...

instead of

create table #t (ID int, Name nvarchar(100) )
insert into #t ...
drop table #t
查看更多
登录 后发表回答