how to find a connection string value for a session in sql server? I know there was a similar question before at SO as shown here
However, that answer really does not address my question.
So here is my scenario, and I will demo it with PowerShell.

The following code will create two sessions on my local sql2016 instance

#The only difference in the two connection strings is [pooling] property, the $connstr_1 has pooling=true, while the $connstr_2 has pooling=false.

$connstr_1 = "data source=localhost\sql2016; initial catalog=master; trusted_connection=true; app=ConnPoolTest; pooling=true";
$SqlConnection1 = New-Object System.Data.SqlClient.SqlConnection($connstr_1)


$connstr_2 = "data source=localhost\sql2016; initial catalog=master; trusted_connection=true; app=ConnPoolTest; pooling=false";
$SqlConnection2 = New-Object System.Data.SqlClient.SqlConnection($connstr_2)

$SqlConnection1.Open()

$SqlConnection2.Open();


My question is on sql server side, how can I know which session's connection string has pooling property set to true and which set to false?
My question is on sql server side, how can I know which session's connection string has pooling property set to true and which set to false?


You generally won't and can't. The connection string isn't sent to SQL Server, it's a directive for the driver on what information and options it needs in order connect and how it should act in certain situations. The connections string itself, however, is not sent to SQL Server and it's generally not possible to reconstruct it in its entirety just form the information surfaced by SQL Server.

In your example, the pooling options tells the driver whether or not to use connection pooling. SQL Server doesn't care about this, nor does it know about this as it's entirely a driver/application construct.