开发者

Scope of global temporary table relative to ADO.NET database connection?

开发者 https://www.devze.com 2022-12-20 06:24 出处:网络
SQL Server books online states the following about visibility (scope?) of temporary tables: Temporary Tables You can create local and global temporary tables.

SQL Server books online states the following about visibility (scope?) of temporary tables:

Temporary Tables

You can create local and global temporary tables. Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.

I want to understand how the scope of the global temporary table relates to an ADO.NET database connection. Will a global temp table created during an ADO.NET connection persist beyond that connection for future connections to use? What about parallel ADO.NET connections that start and stop together?

I'm not seeing the ass开发者_如何学Cociation between Microsoft's use of the word session in SQL context and the word connection in ADO.NET context, if they're one in the same or not.


they are the same, a connection gets a session SPID, the table should be there until it is dropped or you restart the sql server instance

in one window do this

create table ##temp ( ID int)
insert ##temp values (1)

now from another connection do this

select * from ##temp
0

精彩评论

暂无评论...
验证码 换一张
取 消