SQL Server – Cannot Find Old Connection String

sql server

Cannot find old connection string connecting to old database and not new one that has been defined. We have changed web servers on Azure and cannot find the reference to the old database because our IIS sites are still hitting the old database as well as the newly defined one.

I am hoping this is not edge case and someone has had this problem. There are a lot of variables to this problem and know anyone reading this will have questions. Our new sites are working on new SQL but when we shut down the old one our sites break and error out. I am thinking something to do with session state and checked all the conn strings in IIS and found no reference whatsoever to the old SQL Server.

Best Answer

To add on to what Max is saying, you could use the following to get you the sql info and use the port information and sql text to figure out which service is doing what and then use those additional clues to help you isolate where it's coming from.

SELECT 
   des.host_name
    , des.program_name
    , des.login_name
    , dec.client_net_address
    , dec.client_tcp_port
    , db_name(a.dbid) as db_name
    , object_name(a.objectid) as object_name
    , a.text as sql_text
FROM sys.dm_exec_sessions des
    INNER JOIN sys.dm_exec_connections dec ON des.session_id = dec.session_id
    CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) a
WHERE des.is_user_process = 1;