在sql server 2008 r2中的存储过程中的@temp表 [英] @temp table in stored procedure in sql server 2008 r2

查看:169
本文介绍了在sql server 2008 r2中的存储过程中的@temp表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i创建了一个存储过程,我已声明一个@temptable表n插入n从中获取行。



我的问题是,



i创建了这个@temptable,其中我正在插入数据n取出它。

是否需要内存,

我是否必须删除表格中的行...



存储过程:

Hi guys,

i have created one stored procedure, where i have declare one @temptable table n inserting n fetching rows from it.

My question is,

i have created this @temptable in which i'm inserting data n fetching it.
does it take the memory,
do i have to delete the rows n table..

stored procedure:

DECLARE @MaxDate DATE

SELECT @MaxDate = MAX(JobDate) from tbl_etsjob where JobDate <= @ReportDate

print @MaxDate

insert into @TempTable
select 
	  JobID,
	  UnitID ,
      DepartmentID ,
      JobDate ,
      UnitStatus ,
      Rig ,
      Well ,
      JobProcess ,
      NPSJob ,
      CrewStatus ,
      Operator ,
      js.JobStatus
from tbl_etsjob j
INNER JOIN tbl_JobStatus js on js.Ets_JobID = j.JobID
where JobDate = @MaxDate





我必须删除语句是否正在获取。??释放记忆



请告诉我们





谢谢



i have to delete statement are fetching or not.?? to free the memory

plz let me know


Thanks

推荐答案

创建它们的会话完成后会自动丢弃临时表,因此您无需明确删除它们。



但是,这通常适用于#prefixed tables(或##前缀全局表) - 因此它将取决于@temptable变量中的内容!
Temporary tables are automatically discarded when the session that created them is completed, so there is no need for you to explicitly delete them.

However, this normally applies to # prefixed tables (or ## prefixed global tables) - so it will depend to an extent on what is in your @temptable variable!


这篇关于在sql server 2008 r2中的存储过程中的@temp表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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