编译数据库项目时如何处理临时表 [英] How to deal with temp tables when compiling database project

查看:95
本文介绍了编译数据库项目时如何处理临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们刚刚创建了一个包含多个数据项目的解决方案.我们继承了该系统,并希望进行数据库清理,但是当我们编译某些数据库时,我们得到表,id等不存在的错误,并且这种错误发生在存储过程中创建临时表的地方.

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.

比方说,存储的proc创建了一个temp表,最后编译器抱怨该表被丢弃,并说该表不存在(在数据库模式中).我们如何解决这个问题?我找不到任何设置吗?

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?

谢谢.

推荐答案

Microsoft Connect中已针对此问题提交了一个错误,并建议了一种解决方法:使用表变量而不是临时表.因此,使用

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 ...

代替

create table #t (ID int, Name nvarchar(100) )
insert into #t ...
drop table #t

这篇关于编译数据库项目时如何处理临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆