What is considered a session in sql server. I'm trying to use sp_getapplock and the documentation states:
Locks placed on a resource are associated with either the current transaction or the current session. Locks associated with the current transaction are released when the transaction commits or rolls back. Locks associated with the session are released when the session is logged out. When the server shuts down for any reason, all locks are released.
'Locks associated with the session are released when the session is logged out'.
I need to know what is considered a session. connecting using management studio is a session to the database; using asp.net to connect to sql server also creates a session.
What if I use ADO .net and connection pool, is every connection in the connection pool is considered to be a different session?
A SQL session is an occurrence of a user interacting with a relational database through the use of SQL commands. When a user initially connects to the database, a session is established.
In SQL Server Management Studio, right click on Server, choose "Activity Monitor" from context menu -or- use keyboard shortcut Ctrl + Alt + A .
A session represents the connection between an application and the relational database that stores its persistent objects. TopLink provides several different session objects that all implement the same Session interface.
Literally : Connection is Physical Communication Channel and Session is a state of information exchange. A Connection may have multiple sessions . The connection is the physical communication channel between SQL Server and the application: the TCP socket, the named pipe, the shared memory region.
if I use ADO .net and connection pool, is every connection in the connection pool is considered to be a different session?
Sort of. Just about every time you open/close a new connection, that's a single session. However, one of the "features" of the connection pool is that it doesn't always open/close on command, and when it sees you're opening and closing a bunch of connections repeatedly it will use a single connection behind the scenes, which I believe results in a single session on sql server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With