How to deal with temp tables when compiling database project

試著忘記壹切 提交于 2019-12-07 21:46:58

问题


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:


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


来源:https://stackoverflow.com/questions/6210725/how-to-deal-with-temp-tables-when-compiling-database-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!