What is the difference between a connection and a session and how they are related?
|
The connection is the physical communication channel between SQL Server and the application: the TCP socket, the named pipe, the shared memory region. The session in SQL Server corresponds to the Wikipedia definition of a session: a semi-permanent container of state for an information exchange. In other words the sessions stores settings like cache of your login information, current transaction isolation level, session level Normally there is one session on each connection, but there could be multiple session on a single connection (Multiple Active Result Sets, MARS) and there are sessions that have no connection (SSB activated procedures, system sessions). There are also connections w/o sessions, namely connections used for non-TDS purposes, like database mirroring |
|||
|
|
|
I treat them as synonyms, but I always think of them in an order. You must open a connection in order to create a session. They are often used interchangeably. People refer to connections and sessions as if they are the same, even in the MSDN documents. |
|||
|
|