application connections MSSQL

we need to do some documentation around which SQL databases are serving which applications for asset management and CMDB purposes. Some of which have been handed over to support with no real documentation on what databases/SQL instances serve which applications, and which servers the applications are installed upon. Would there be any clues within SQL Server on which apps the databases are connected to, and what servers those apps are hosted on? Any queries which may give some clues would be a huge help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
You may start with

SELECT  DB_NAME(S.[dbid]) AS DatabaseName ,
        CAST(RTRIM(S.hostname) AS NVARCHAR(128)) AS HostName ,
        CAST(RTRIM(S.loginame) AS NVARCHAR(128)) AS LoginName ,
        CAST(RTRIM(S.[program_name]) AS NVARCHAR(128)) AS ProgramName ,
        CAST(RTRIM(S.[status]) AS NVARCHAR(128)) AS [Status] ,
        COUNT(S.[dbid]) AS Connections
FROM    sys.sysprocesses S
WHERE   S.[dbid] > 0
GROUP BY S.[dbid] ,
        S.loginame ,
        S.[program_name] ,
        S.[status] ,

Open in new window

But ProgramName is an optional information given be the connecting program.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
IMHO, the best thing is to go application by application and check their configuration settings to find out the connection string.
Anthony PerkinsCommented:
Or you could always do the "Scream" test.  Take the database offline and wait ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.