Search code examples
sql-serverconnection-poolingdynamic-management-views

get connection with connection_id


When I execute

select * from sys.dm_exec_connections

there will be a resulting column connection_id.

Now, I am searching for the connectionstring which corresponds to this connection_id. Can someone help me, where I can find this information?


Solution

  • You can't find connection string info ,like the way it is deployed in web.config..

    To identify and isolate connections,you have to use Application name parameter in connection string

    "Data Source =localhost; Initial Catalog=tsql2012;Integrated Security=SSPI;Application Name=testapp";

    So whenever application using connection string like above , makes a connection to SQLServer,you can identify it like below..

    select program_name,client_net_address from sys.sysprocesses sp
    join
    sys.dm_exec_connections ec
    on ec.session_id=sp.spid
     where program_name='testapp'