SQL Server 临时表和连接池 [英] SQL Server Temp Tables and Connection Pooling

查看:36
本文介绍了SQL Server 临时表和连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对 SQL Server 运行的多用户 ASP.NET 应用程序,并希望让 StoredProcA 创建一个 #temptable 临时表 - 而不是表变量 - 来插入一些数据,然后分支到 StoredProcB、StoredProcC 和 StoredProcD 进行操作#temptable 每个业务规则中的数据.

I have a multi-user ASP.NET app running against SQL Server and want to have StoredProcA create a #temptable temp table - not a table variable - to insert some data, then branch to StoredProcB, StoredProcC, and StoredProcD to manipulate the data in #temptable per business rules.

Web 应用程序在与 SQL 通信时使用连接池.我会为每次调用 StoredProcA 获得一个新的#temptable 暂存区吗?还是连接池会在用户之间共享#temptable?

The web app uses connection pooling when talking to SQL. Will I get a new #temptable scratch area for each call of StoredProcA? Or will the connection pooling share the #temptable between users?

推荐答案

连接池(使用任何现代版本的 SQL Server)将调用 sp_reset_connection 重用连接时.这个存储过程,除其他外,删除连接拥有的任何临时表.

Connection pooling (with any modern version of SQL Server) will call sp_reset_connection when reusing a connection. This stored proc, among other things, drops any temporary tables that the connection owns.

这篇关于SQL Server 临时表和连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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