Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2010-06-08 : 16:39:56
|
I am doing the following in SSMS (2008)Query window 1:create table #t2 (id int)if OBJECT_ID ('tempdb..#t2') is not null select 'Y' else select 'N'Query window 2:if OBJECT_ID ('tempdb..#t2') is not null select 'Y' else select 'N'In window 1 I am getting the answer 'Y' and window 2 'N'. What I want to know is, how sql server is able to defferentiate between the connection, though the code is same? (I have some more questions, that will follow depending on the answers to above qiestions.)------------------------I think, therefore I am - Rene Descartes |
|
jimmycjen
Starting Member
15 Posts |
Posted - 2010-06-08 : 16:55:55
|
Each window is a different session. |
 |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2010-06-08 : 17:06:04
|
quote: Originally posted by jimmycjen Each window is a different session.
I know, my question is how does sql server knows that the sessions are different? The query is same! Apparently sql server is doing more than executing the plain query. My next question: Is sql server connection pool aware?------------------------I think, therefore I am - Rene Descartes |
 |
|
jimmycjen
Starting Member
15 Posts |
Posted - 2010-06-09 : 12:29:32
|
Here is how: The Database Engine does this by internally appending a numeric suffix to each local temporary table name for each session. For more details, see:ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/1e068443-b9ea-486a-804f-ce7b6e048e8b.htm |
 |
|
|
|
|